Detect lazy loading images and execute function when a certain image has loaded

I have a module which displays an image. On window.load, I execute some code to setup a jQuery library. Now when I use a lazy load plugin like JetPack or BJ Lazy Load, the img src is replaced by a placeholder. Since my plugin thinks the page has loaded, it starts setting up the library but it ends up with a wrong image size. When the actual image is then loaded, everything gets messed up.

Do you know a good way of detecting lazy loading images universally and executing a function after the actual image has loaded? My plan is to use this function to then re-setup the library.

Thank you for your ideas and suggestions

Read more here:: Detect lazy loading images and execute function when a certain image has loaded

Leave a Reply

Your email address will not be published. Required fields are marked *