Specify Default Images for your <img>
tags to be loaded when their images fail to load.
Simply place the script in default-src.js
at the bottom of your page.
if (jQuery) { | |
$('img[default-src]').each(function () { | |
var $elem = $(this); | |
this.onerror = function () { | |
if ($elem.attr('src') != $elem.attr('default-src')) $elem.attr('src', $elem.attr('default-src')); | |
} | |
}); | |
} |
I think just a method would even do. Below is an untested code:
Usage would be: