Skip to content

Instantly share code, notes, and snippets.

@jamielovelace
Created August 8, 2014 09:39
Show Gist options
  • Select an option

  • Save jamielovelace/cb7022bf465a5188c792 to your computer and use it in GitHub Desktop.

Select an option

Save jamielovelace/cb7022bf465a5188c792 to your computer and use it in GitHub Desktop.
Replace .svg with .png - with modernizr
/*
* Thanks to Todd Motto ( @toddmotto )
* http://toddmotto.com/mastering-svg-use-for-a-retina-web-fallbacks-with-png-script/
*/
if(!Modernizr.svg) {
var imgs = document.getElementsByTagName('img');
var endsWithDotSvg = /.*\.svg$/
var i = 0;
var l = imgs.length;
for(; i != l; ++i) {
if(imgs[i].src.match(endsWithDotSvg)) {
imgs[i].src = imgs[i].src.slice(0, -3) + 'png';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment