帝国CMS熊掌号缩略图调用方法
2020-04-10 站长 站长日志
熊掌号缩略图调用方法
<?php$str=$navinfor['newstext'];$str = str_replace('https://xxxxxhttp://www.cmsyuanma.com/d/file/','http://www.cmsyuanma.com/d/file/',$str);$str = str_replace('http://www.cmsyuanma.com/d/file/','https://xxxxxxhttp://www.cmsyuanma.com/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字段,把所有图片绝对路径替换成http://www.cmsyuanma.com/d/file/相对路径,然后在把相对链接替换为统一的绝对路径,下面开始循环数组。如果图片数量大于等于3,就输出3张图,相反只输出一张图。
