是否可以在调整大小时使交换基础 6 替换属性data-src上的路径而不是图像的src?
在 DIV 中的背景图像上具有相同的行为,将data-src上的路径替换为style="background-image。
我试图仅在视口上显示图像,某种使用交换的手动延迟加载。
页面加载时我正在删除 src:
/*Stop Interchange Background Images loading images*/
$(".delay").each(function(){
var img_src = $(this).attr('src');
$(this).attr("data-src", img_src);
$(this).attr('src', '');
});
/*Stop Interchange Background Images loading for DIVs and Slides*/
$(".backImg").each(function(){
var img_backImg = $(this).css('background-image');
$(this).attr("data-src", img_backImg);
$(this).css('background-image','');
});
然后,一旦图像接触视口,就会添加 src 或背景图像。这运作良好,但我现在的问题是图像在调整大小时自动出现。
因此,如果 Interchange 使用data-src更改url,我可以获取 URL 并将其粘贴到我需要的位置。
希望这对可以帮助我的人有意义。
非常感谢!