帝国CMS熊掌号缩略图调用方法_帝国cms教程-大众资源网

熊掌号缩略图调用方法

<?php
$str=$navinfor['newstext'];
$str = str_replace('https://xxxxxhttps://www.11dz.cn/d/file/','https://www.11dz.cn/d/file/',$str);
$str = str_replace('https://www.11dz.cn/d/file/','https://xxxxxxhttps://www.11dz.cn/d/file/',$str);
preg_match_all('/https:.*?(jpg|gif|png|bmp)/' ,$str, $img);
$num=count($img[0]);
if($num>=3){
        echo '"'.$img[0][0].'"'.',';
        echo '"'.$img[0][1].'"'.',';
        echo '"'.$img[0][2].'"';
}
else if($num>=1){
        echo '"'.$img[0][0].'"'.',';
}
else{ 
}
?>

调用newstext字段,把所有图片绝对路径替换成https://www.11dz.cn/d/file/相对路径,然后在把相对链接替代为统一的绝对路径,下面开始循环数组。如果图片数量大于等同于3,就输出3张图,相反只输出一张图。

发表评论