SVG Files and auto-format

Options
pludlow
pludlow Member Posts: 17
edited August 2023 in Developer APIs

I have some SVG files in Cloudinary. On upload I apply an incoming transformation of "fl_sanitize" so that they should be viewable in the browser instead of downloaded.

For the delivery URL I add /q_auto/f_auto, so that if a receiving browser/app doesn't support SVG it will be converted into PNG, WEBP, or whatever. I would like the format to stay SVG when supported, but auto-format seems to always convert to another file format.

I have tested this in Chrome and Safari, and each browser gives me something different than SVG. (Browser support is high for this, https://caniuse.com/svg) Is there a way to accomplish the behavior I would like and passthrough SVG when supported?

Tagged:

Best Answer

  • pludlow
    pludlow Member Posts: 17
    Answer ✓
    Options

    There is a solution to this. I worked with support and they enabled "SVG" as an auto-format in my environment. Once that was done, specifying f_auto allowed SVG files to persist as SVG files. Things to note:

    • The fl_sanitize flag should be used on either the incoming transformation for any of your SVG files, or it should be used in the delivery URL (this will be ignored for any image type that isn't SVG)
    • If you access an SVG file directly you'll likely need to use the fl_sanitize flag in the delivery URL as it will include a Content-Disposition header.
    • If you use the SVG as part of an <img> tag you won't need to use fl_sanitize in the delivery URL if the file was sanitized earlier (incoming transformation)
    • This setting is done per environment, so if you have multiple environments it will need to be added to each.

Answers

  • Tamara
    Tamara Member, Cloudinary Staff Posts: 110
    Options

    Hi there,

    Thanks for reaching out and sorry for the late reply!

    Could you kindly provide your cloud name along with a few examples? If you prefer not to share this information publicly, you can send it in a new private ticket here.

    Looking forward to your response!

    Best regards,

    Tamara

  • pludlow
    pludlow Member Posts: 17
    Options

    Tamara, I'll open up a ticket with that information. Thanks.