Provide svg content

Hi there,

I’d love to display my svg’s inline and it would be very convenient to be able to fetch the xml content of an svg file from the graphql api. Do you plan to integrate this any time soon?

Cheers!

If I remember right, I read at some point that Imgix does support serving of unmodified SVG images, but they turn it on manually per-account as most customers want everything converted to bitmaps by default. So you’d have to run your own Imgix instance, it wouldn’t work with the Dato one.

1 Like

Ah I see, thanks for your reply! At least that’s a solution… even though I’d prefer to always have it :smiley:

Out of interest what’s the workflow that ends up in SVGs entering Dato? I make liberal use of SVGs for icons and other vector graphics, but since they’re all tiny I keep them in the main website codebase and include them from there.

Hey! Sorry for answering so late: I’d need SVG content to display icons or logos that I can’t include in my codebase because I don’t have them. E.g. you create a theme and want to let the user upload a something. My solution to get the logo is now to download it before building my site but that’s more a workaround. For Icons I could keep them in my code base and give my client a select field containing all the icon names… but is that a great solution? I’d also have to give him a table containing all the icon names as I can’t display the icons in the select field.

hey @marc sorry if I’m late as well, but is it something we can do on our Imgix account side? Happy to help on this if you need me!

Was this resolved? I’m curious to try allowing Imgix to rasterize SVG’s as mentioned here:
https://support.imgix.com/hc/en-us/articles/204280985 - but using gatsby-source-datocms - it seems that the query results in a null result for fluid

{
  datoCmsAsset(filename: {eq:"countryus.svg"}) {
    filename
    format
    fluid(imgixParams: {auto: "compress"}) {
      src
    }
  }
}
{
  "data": {
    "datoCmsAsset": {
      "filename": "countryus.svg",
      "format": "svg",
      "fluid": null
    }
  },
  "extensions": {}
}

It would be a bit of a hacky solution, but I assume you could use the JSON field to serve the XML as a string inside JSON and then use DOMParser - Web APIs | MDN