Created
January 18, 2013 12:53
-
-
Save anthonyringoet/4564375 to your computer and use it in GitHub Desktop.
swap out svg for a bitmap image src if svg is unsupported
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
// if svg is unsupported (modernizr test) | |
// look for data-svg-fallback attr | |
// and switch out src on those images | |
(function (Modernizr, $, undefined) { | |
if(!Modernizr.svg){ | |
var $elems = $('img[data-svg-fallback]'); | |
$elems.each(function(index){ | |
var img = $(this); | |
img.attr('src', img.attr('data-svg-fallback')); | |
}); | |
} | |
})(Modernizr, jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment