I am trying to inline an (optimized) SVG using the svg() helper. Somehow this SVG shows up on all my desktop browsers, but on neither of my iOS (iPhone or iPad, Safari, Chrome and/or Firefox) devices.
And as said … this works in my desktop browsers. If i now edit my source and hardcode the SVG into the site myself using the following, it shows up on iOS:
Afaik the svg() helper only reads the contents of the svg file and echos it. So, does it work if you exactly copy the contents of the svg file and paste it in your code where you used the svg helper? If that doesn’t work, it most probably is a problem with your SVG file?
Well, I thought the same. But that could actually not be the solution to include all the other stuff in the actual SVG. And the file is perfectly fine sadly. But thanks for your input!
If there’s more “stuff” in the SVG, then it is displayed anyway if you use the svg helper as that’s what it does: it “dumps” the SVG file as inline content.
Ok, that was a bit misleading. I thought you were saying that something is wrong with the svg helper. But that seems to be rather an issue with mobile Safari, at least newer versions, because the SVG comes out alright even without the extended tags on my old iPhone.
As I wrote, the svg helper does nothing but output the contents of your svg file.
How are the SVGs created? I find exporting from Sketch and then running through SVGOMG works great with Kirby. Ive done the same from Affinity Designer too. I find Illustrator adds alot of unneccesary stuff to the SVG.
Oh sure… i actually use Imgoptim which can do it in batch if you have SVGO globally installed. You can just turn it on in the imageoptim preferences. Drag and drop ftw.
Maybe it’s due to missing with and height attributes in the SVG? IIRC I’ve had issues in the past because of that (but it was in IE I think, not mobile safari).
+1 for the idea of @bvdputte with the width="" and height="" attributes.
If your main reason for using inline SVG is not to minimize the requests but to style the SVG via CSS you could also use the <object> tag to include the SVG.