Skip to content

Instantly share code, notes, and snippets.

@iliman
Created April 2, 2015 18:53
Show Gist options
  • Save iliman/e8196c276000212509ed to your computer and use it in GitHub Desktop.
Save iliman/e8196c276000212509ed to your computer and use it in GitHub Desktop.
//Your SVG
var mySVG = '<svg xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20"><defs><linearGradient osb:paint="solid"><stop offset="0"/></linearGradient><linearGradient osb:paint="solid"><stop offset="0"/></linearGradient><marker orient="auto" overflow="visible"><path d="M-10 0l-4 4L0 0l-14-4 4 4z" fill-rule="evenodd" stroke="#000" stroke-width=".8pt"/></marker><marker orient="auto" overflow="visible"><path d="M10 0l4-4L0 0l14 4-4-4z" fill-rule="evenodd" stroke="#000" stroke-width=".8pt"/></marker></defs><g fill="none" fill-rule="evenodd" stroke="#aaa" stroke-width="1.868"><path d="M.66.66l18.68 18.68"/><path d="M19.34.66L.66 19.34"/></g></svg>';
//Generate base64 svg
var mySVG64 = window.btoa(mySVG);
//Get your base64 svg in console
console.log("url('data:image/svg+xml;base64,"+mySVG64+"')");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment