tuupola/jquery_lazyload — pull request #16 by Frexuz (2011-12-30 18:52:04+00:00)
Title: Added callbacks

Hi! I had a situation recently where I needed to know if an image did successfully load or not.

In my case I used a transparent 1x1 gif instead of a grey placeholder, because I showed a spinner animation as the image's background (css). But because my loaded images were transparent in some places, the spinner showed through when the full image appeared. So I added a success callback to be able to remove the spinner when an image had fully loaded.

There was also a case when the data-original url did not actually exist. Then the spinner would always be visible (not a very good user experience). So I also added a timeout callback (default 10 seconds) to remove the spinner then.

This makes the plugin a little bit more dynamic, with little extra plugin code. Take a look and see if you like it! :)