Pure CSS
1 2 3 4 5 |
.svg{ background-image: url('image.png'); background-image: none,url('image.svg'), url('image.png'); background-size: 100% 100%; } |
Using Modernizer + jQuery
1 2 3 4 5 |
if(!Modernizr.svg) { $('img[src*="svg"]').attr('src', function() { return $(this).attr('src').replace('.svg', '.png'); }); } |
Custom detection of SVG
1 2 3 4 5 6 7 |
var supportsSVG = function() { return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1"); } if (!supportsSVG()) { // work your magic } |