Skip to content

Instantly share code, notes, and snippets.

@herschel666
Created February 24, 2013 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herschel666/5024092 to your computer and use it in GitHub Desktop.
Save herschel666/5024092 to your computer and use it in GitHub Desktop.
PNG-Fallback for SVG-Images. Inspired by http://codepad.co/s/02aac9, but realized without jQuery-Dependency. Only Modernizr is needed.
var rSvg = /\.(svg)$/;
if ( !Modernizr.svg ) {
for ( var i = 0, img; img = document.images[i]; i +=1 ) {
if ( !rSvg.test(img.src) ) continue;
img.src = img.src.replace(rSvg, '.png');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment