Project

General

Profile

Actions

Defect #44126

open

SVG attachments are displayed as XML source instead of image previews

Added by Go MAEDA 1 day ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Attachments
Resolution:
Affected version:

Description

In attachments show page, SVG attachments are displayed as XML source code instead of being shown as image previews. They should be displayed with the normal image preview, like other image attachments.

This happens because SVG files are detected as both images and text files. While their MIME type (image/svg+xml) identifies them as images, Attachment#is_text? also returns true because SVG files are XML documents supported by syntax highlighting.

The fix is to give image previews priority over text previews when deciding how to display an attachment. As a result, SVG files, which qualify as both image and text attachments, are displayed using the existing image preview.

This change remains safe because it does not embed or interpret SVG content within the page. Instead, it uses the existing image preview mechanism, which renders the attachment through an img tag with the attachment download URL as its src. The SVG is therefore handled as an image resource rather than as page content.

Before:

After:


Files

before@2x.png (52.7 KB) before@2x.png Go MAEDA, 2026-05-29 05:59
after@2x.png (24.8 KB) after@2x.png Go MAEDA, 2026-05-29 06:00
svg-preview-fix.patch (2.02 KB) svg-preview-fix.patch Go MAEDA, 2026-05-29 06:01

No data to display

Actions

Also available in: Atom PDF