Defect #44126
closedSVG attachments are displayed as XML source instead of image previews
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
Updated by Go MAEDA about 1 month ago
- Target version changed from Candidate for next major release to 7.0.0
Setting the target version to 7.0.0.
Updated by Go MAEDA about 1 month ago
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the fix in r24713.