HTML
<?php
$newgoods_info = str_replace("<img ", "<img class='lazy' ", $info['goods_info']);
$newgoods_info = str_replace("src=", "data-original=", $newgoods_info);
echo $newgoods_info;
?>
JS
<script src="{:CUSTOM_TEMPLATE_PATH}Index/index/js/jquery.lazyload.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("img.lazy").lazyload({
effect: "fadeIn"
});
});
</script>
最终效果html
<img src="/Uploads/Editor/gh_4df8efbb2caf/2015-12-22/56790323d8b21.jpg" class="lazy" data-original="/Uploads/Editor/gh_4df8efbb2caf/2015-12-22/56790323d8b21.jpg" style="float: none; display: block;" title="image_01.jpg">