问题描述
我正在尝试为使用 jQuery插件创建的轮播内的图片实施延迟加载。
I'm trying to implement a lazy load for images that are inside a carousel created with the carouFredSel jQuery plugin.
您有任何建议或者您已经取得了类似的成果吗?它似乎默认不能这样做。
Do you have any advice or have you already achieved something similar? It seems that it can't do it by default.
推荐答案
@Stefano-你到目前为止尝试了什么? (如果可以,显示一些代码)。它将帮助我们确切了解最新情况。
@Stefano- what have you tried so far? (Show some code if you can). It will help us see exactly whats going on.
根据经验,延迟加载,请确保将占位符图像作为src放在html中,如: SRC = IMG / grey.gif
。这个图像可以是任何东西 - 但大多数人使用一个小的1px盒子b / c它的光线供服务器传输。绑定将特定类放入html的< img>
src中也是一个好主意,例如: class =lazy
。
As a rule of thumb with lazy loading, make sure you put a place holder image as the src in your html like: src="img/grey.gif"
. This image can be anything - but most folks use a small 1px box b/c its light for the server to transfer. It's also a good idea for binding to put a specific class in your html's <img>
src, like: class="lazy"
.
这是你的html src的一个例子:
So an example of your html src:
<img class="lazy" src="img/grey.gif" data-original="img/example.jpg" width="640" height="480">
然后在你的jquery函数中放入 -
Then in your jquery function put-
$("img.lazy").lazyload(); //this is why the binding of a class is helpful
读取的一些好参考是和。如果您对Fred有一个关于lazyload()的特定问题,请发布一些代码。
Some good references to read are here and here. Post some code if you have a specific question regarding lazyload() with Fred.
这篇关于jQuery:使用carouFredSel插件延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!