0

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...

Fluidbyte
  • 5,162
  • 9
  • 47
  • 76
  • 1
    http://stackoverflow.com/questions/92720/jquery-javascript-to-replace-broken-images, http://stackoverflow.com/questions/1977871/check-if-an-image-is-loaded-no-errors-in-javascript – Andreas Oct 23 '12 at 14:07
  • @mgraph - the image was removed, doesn't exits - broken path. – Fluidbyte Oct 23 '12 at 14:09

0 Answers0