帝国cms使用教程 帝国CMS熊掌号缩略图调用方法

帝国CMS教程

熊掌号缩略图调用方法

<?php$str=$navinfor['newstext'];$str=str_replace('https://xxxxxhttp://www.11px.cn/d/file/','http://www.11px.cn/d/file/',$str);$str=str_replace('http://www.11px.cn/d/file/','https://xxxxxxhttp://www.11px.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].'"';}elseif($num>=1){echo'"'.$img[0][0].'"'.',';}else{}?>

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