Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active CSS Pipeline breaks URI-encoded SVG, set as background-image in CSS. #864

Closed
ulilu opened this issue May 30, 2016 · 5 comments
Closed

Comments

@ulilu
Copy link

ulilu commented May 30, 2016

When activating the Configuration > System > Asset > CSS Pipeline, all SVGs implemented via URI-encoded background-images in CSS disappear.

From what i can see, there is a very specific reason – the Grav processing seems to strip out the whitespace between the "%3Csvg" and the "xmlns=", thus rendering the svg invalid for the browser:

background-image: url("data:image/svg+xml;charset=utf8,%3Csvgxmlns='http://www.w3.org/2000/svg' ...

(And for those wondering about the peculiar character escaping: The optimized URI-encoding is produced via this script (including explanation): https://codepen.io/tigt/post/optimizing-svgs-in-data-uris)

@rhukster
Copy link
Member

Can you provide please me with a .css file to test with?

@ulilu
Copy link
Author

ulilu commented May 31, 2016

sure thing, here you go.
(just create an empty div with a class of "mucem")
mucem.css.zip

@rhukster
Copy link
Member

So the problem was that the CSSMin library we are using (part of Minify library) was stripping out these spaces. I did a little research and found a newer (better?) library that seems to do a more reliable job.

I've set this this new library as the default, and it might fix a few other issues i've seen in the past. It is possible to set Grav to use the 'old' library for CSS and JS independently.

This is available in develop and will be available in Beta 6 which i plan on releasing tomorrow.

@rhukster
Copy link
Member

Actually i might try another couple of libraries to make sure i've picked the best one.

Also you can simply disable CSS Minify in system config to fix this issue temporarily.

@ulilu
Copy link
Author

ulilu commented May 31, 2016

Thanks, will do! Can't wait to test the new beta 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants