Currently, ActiveStorage.variable_content_types includes the following image formats:
- image/png
- image/gif
- image/jpeg
- image/tiff
- image/bmp
- image/vnd.adobe.photoshop
- image/vnd.microsoft.icon
- image/webp
- image/avif
- image/heic
- image/heif
I’ve tried with both image processors (vips and imagemagick), adding SVG image to the above list and processing it works as expected:
# config/application.rb
config.active_storage.variable_content_types << "image/svg+xml"
# show.html.erb
<%= image_tag @model.logo.variant(format: :webp).processed.url %>
I couldn’t find any discussion on this, so, I was wondering if SVG was left out for a reason. If not, if it can be added to the variable image list.
Note. Specifically, I’m coming from Inline SVGs not displayed when loaded from ActiveStorage. By allowing SVG to be variable, developer could render SVG as a variant in one of the web image types with no further configuration or security risk.