Created
February 24, 2013 14:48
-
-
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.
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
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