Im using Lazysizes and trying to do something if user lose internet connection and keep scrolling, then there is no image shown How can i make if images are failed to donwload to replace them with src image? i tried to put in src loading image and replace on error but is not working because it return error again and again ...
document.addEventListener('error', function(e){ if(e.target.nodeName == 'IMG'){e.target.src = e.target.getAttribute('src')} }, true);
HTML
<div class="image">
<a href="<?php echo $product['href']; ?>">
<img src="<?php echo $preloader?>" data-src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive lazyload" />
</a>
</div>