获取文章内第一张图片做为ThinCMF缩略图
获取文章内第一张图片做为ThinCMF缩略图
在application/Common/Common/funtion.php中添加函数:spl_post_thumb()
| 1.2.3.4.5.6.7.8.9.10.11. | function spl_post_thumb($content){
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$content,$matchContent);
if(isset($matchContent[1][0])){
$temp=$matchContent[1][0];
return $temp;
}else{
$temp="./images/no-image.jpg";//如何文章内没有图片,此处可以改为你设好的系统默认图地址
return $temp;
}
} |
这样就可以在模版中直接调用此函数了。
原文连接:http://b.voyog.com/index.php/article/index/id/17/cid/8.html
CMF交流群:10432283


