I'm setting up a script to load images (we have a lot of them) after the page has loaded using the following:
HTML:
<img class="dload" data-src="/path/to/image.jpg">
JS:
$('img.dload').each(function() {
var img = $(this);
var src = img.data('src');
img.attr('src',src);
});
As we have a lot of images there's a high probability that we may have broken images, so I'm wondering the best way to run onerror
against a dynamically loaded src
. I'd figure the image would need to successfully run the .attr()
command before it could check...