As title says. I want to be able to determine if a background img failed to load. I looked around and seen loads of information but sadly cant get any of them to work for me.
I seen a pretty good one describing to use a plugin called waitForImages located: https://github.com/alexanderdickson/waitForImages
I cant seem to get the failed to load work. Now, if someone has a better way im all open! As long as i can get an alert to say it failed. I pushed in a fake URL so it should come back with link not working.
Code:
$("#cover-art").css("background-image", 'url("/assets/img/cover-adio.png")');
$('#cover-art').waitForImages(function() {
alert('All images have loaded.');
}, function(loaded, count, success) {
alert(loaded + ' of ' + count + ' images has ' + (success ? 'loaded' : 'failed to load') + '.');
$(this).addClass('loaded');
});