Defect #44126
openSVG 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
No data to display