Skip to content

Instantly share code, notes, and snippets.

@anthonyringoet
Created January 18, 2013 12:53
Show Gist options
  • Save anthonyringoet/4564375 to your computer and use it in GitHub Desktop.
Save anthonyringoet/4564375 to your computer and use it in GitHub Desktop.
swap out svg for a bitmap image src if svg is unsupported
// 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