Problem replacing svg's minified

Hello everyone!

I’m getting some troubles with the replace functionality in Kirby panel when trying to replace an svg minified. I’m getting a 500 internal server error

If the SVG is NOT minified the functionality works perfectly (with jpg, png, and gif too) but when the svg is minified the image replacement doesn’t work at all.

Is this a bug? Anyone has found this problem before and knows how to solve it?

Thank you all!

I’ve worked with minified SVG files just fine. What are you using to minify it? I usually use SVGOMG, and the command line equivalents.

Perhaps you are minifying so hard that some information is lost that Kirby relies on to tell if its a real/valid SVG or not, but im only guessing.

Does it work if you delete the original unminified version, and upload the minified SVG brand new, rather then replacing an existing file?

Hi Jim!

Thank you for your answer :slight_smile:

The client is exporting the files via Illustrator with the minification the program make. But i’ve just tried your tool and i have the same problem yet (maybe i’m going to try to activate/deactivete all the options in SVGOMG in order to try to find which one is messing with the replacement functionality).

Is not just the brand image, this project has a lot of svg images inside the pages and it needs to be updated by the client (not exactly a tech person). So i’ll keep digging in this strange behaviour :slight_smile:

Illustrator is really quite bad at SVG export. The best approach is Sketch + the official SVGO export plugin installed. You can also do with Imageoptim if you have SVGO installed globally on your machine. Just turn it on in imageoptim’s options.

I know these methods to work fine with kirby, i do it all the time. I’m afraid I dont know a good windows way.

last resort, you can do this from the command line…

find ./public/content -name '*.svg' -type f -exec svgo  {} \\;

That will rip through your content folder recursively and optimise any SVG files it finds. if you happen to have the site on a VPS and you can install SVGO on it, you can at least use that in cron job or something so it runs nightly.

Try exporting a straight SVG from Illustrator without choosing the for web options. Then run it through SVGOMG.

Illustrator likes to group things horribly badly. If you export from illustrator to web svg and open it in sketch, youll see the structure is a real mess. If you do the svg work in Sketch without involving Illustrator and export, you will end up with much cleaner file, smaller file.

If sketch isnt an option, you can try Gravit which is cross platform and free to a point.