DZ门户频道文章内容页的图片如何做延迟加载呢?-Discuz教程下载

DZ门户频道文章内容页的图片如何做延迟加载呢?

开通本站Svip会员,全站资源免费下
由于网站图片比较的多,所以想到用JS小插件echo.js做图片延迟加载,目前首页、栏目页的图片均可以找到<img class="lazy" src="#" data-echo="#" />,给class增加class,设置src和 data-echo,但是dz门户内容页是找不到img的,内容页的内容调用只有一个TAG.html" target="_blank" class="relatedlink">标签$content[content]实现,找不到img标签,没办法实现延迟加载,寻求站长和各位朋友的帮助

1、\static\image\editor\editor_function.js第107行。
看这个代码
  1. function insertImage(image, url, width, height) {
  2.         url = typeof url == 'undefined' || url === null ? image : url;
  3.         width = typeof width == 'undefined' || width === null ? 0 : parseInt(width);
  4.         height = typeof height == 'undefined' || height === null ? 0 : parseInt(height);
  5.         var html = '<p><a href="' + url + '" target="_blank"><img src="'+image+'"'+(width?' width="'+width+'"':'')+(height?' height="'+height+'"':'')+'></a></p>';
  6.         edit_insert(html);
  7. }
复制代码
从insertImage字面意思上看就知道是插入图片。
其中
  1. var html = '<p><a href="' + url + '" target="_blank"><img src="'+image+'"'+(width?' width="'+width+'"':'')+(height?' height="'+height+'"':'')+'></a></p>';
复制代码
就是插入的图片内容格式,如果你改成
  1. var html = '<p><a href="' + url + '" target="_blank"><img class="lazy" src="'+image+'"'+(width?' width="'+width+'"':'')+(height?' height="'+height+'"':'')+' data-echo="#"></a></p>';
复制代码
这样发表文章时插入内容的img就带你要的参数。
你需要减小图片大小,有些图片一张就大于1MB,又不是做摄影的,搞那么多高清大图没必要。首页调用的图片最好是缩略图。

全部评论 0

您需要登录后才可以回帖 立即登录
登录
0
0
0
返回顶部