Created
June 28, 2016 05:37
-
-
Save tracend/3dea1aa9faaf9547ba5cc4231df1a1eb to your computer and use it in GitHub Desktop.
Underscore mixin: SVGtoBase64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Underscore mixin: SVGtoBase64 | |
// Usage: background-image: url(data:image/svg+xml;base64,[output]); | |
_.mixin({ | |
SVGtoBase64: function( svg ){ | |
// fallback (to the first item in the document); | |
if( typeof svg != "string") svg = new XMLSerializer().serializeToString(document.getElementsByTagName("svg")[0]); | |
var base64 = window.btoa( svg ); | |
// return the whole css line? | |
return base64; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment