drcigvoy48900
drcigvoy48900
2014-07-07 10:38
浏览 42

来自timthumb来源的Lazyload缩略图?

I'm trying to load about 300+ thumbnails using the following inside a for loop and a
ul id="imagesContainer"

echo "<li><a href=\"$dirname$curimg\" rel='prettyPhoto[gallery2]'><img class='lazy' data-original='img.php?src=$dirname$curimg&amp;w=300&amp;zc=1' width='300' height='300' src='img.php?src=$dirname$curimg&amp;w=300&amp;zc=1' /></a></li>" ;

and just before </body>

$(function() {
 $("img.lazy").lazyload({
     container: $("#imagesContainer"),
     effect : "fadeIn",
     failure_limit : 5
 });
});

My problem is that all images are loaded at the beginning and not as soon as I scroll to them, resulting 300+ requests on page load. Any suggestions?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqqs64238
    dqqs64238 2014-07-07 23:55
    已采纳

    My mistake instead of

    echo "<li><a href=\"$dirname$curimg\" rel='prettyPhoto[gallery2]'><img class='lazy' data-original='img.php?src=$dirname$curimg&amp;w=300&amp;zc=1' width='300' height='300' src='img.php?src=$dirname$curimg&amp;w=300&amp;zc=1' /></a></li>" ;
    

    here is the correct code which works

    echo "<li><a href=\"$dirname$curimg\" rel='prettyPhoto[gallery2]'><img class='lazy' data-original='img.php?src=$dirname$curimg&amp;w=300&amp;zc=1' width='300' height='300' /></a></li>" ;
    
    点赞 评论

相关推荐