在制作对应的wordpress微信小程序后,发现对应的文章中一直存在图片的加载动画,且无法消失。
其原因为懒加载问题,解决方法也很简便。
打开wordpress主题下的\inc\feature.php
将含有lazyload的代码段注释掉即可,即注释类似以下的代码段
//if (cs_get_option('i_function_lazyload_switcher')) {
add_filter ('the_content', 'lazyloadImagesReplace');
function lazyloadImagesReplace($content) {
$loadingImg = get_bloginfo('template_directory').'/assets/images/loading.gif';
if(!is_feed()) {
$content=preg_replace('/<img(.+)src=[\'"]([^\'"]+)[\'"](.*)>/i',"<img\$1data-echo=\"\$2\" src=\"$loadingImg\"\$3>\n<noscript>\$0</noscript>",$content);
// $content=str_replace(" src=", "data-echo=", $content);
}
return $content;
}
//}