How to show a "loading" gif image on top of a image placeholder during lazyload

jquery, jquery-events, jquery-plugins

Solution

I make `demo project` for above your requirement this is working fine for me please use following code for that.

In Head:

<script src="jquery.min.js" type="text/javascript"></script>
    <script src="jquery.lazyload.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $(function () {
                $("img.lazy").lazyload({
                    event: "sporty"
                });
            });
            $(window).bind("load", function () {
                var timeout = setTimeout(function () { $("img.lazy").trigger("sporty") }, 5000);
            }); 
        });
    </script>
    <style type="text/css">
        #container
        {
            height: 600px;
            overflow: scroll;
        }
    </style>

Body :

<div id="container">
        <img class="lazy" width="765" height="574" src="loadingcirclests16.gif" data-original="bmw_m1_hood.jpg" /><br />
        <img class="lazy" width="765" height="574" src="loadingcirclests16.gif" data-original="bmw_m1_side.jpg" /><br />
        <img class="lazy" width="765" height="574" src="loadingcirclests16.gif" data-original="viper_1.jpg" /><br />
        <img class="lazy" width="765" height="574" src="loadingcirclests16.gif" data-original="viper_corner.jpg" /><br />
    </div>

Problem

I am using this jQuery plugin to lazy-load my images. Lazy Loader It is working fine. I just want to show a "loading" image (gif maybe) on top of all those image which are not loaded yet, which disappears when the image loads. Any idea how to do this. FYI: I am using a 1x1 gif image as a placeholder.

Original source