ZblogPHP自动调用文章第一张图为缩略图及随机缩略
发布时间:2019-12-16 11:14:35作者:admin点击:

$temp=mt_rand(1,5);
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
$content = $article->Content;
preg_match_all($pattern,$content,$matchContent);
if(isset($matchContent[1][0]))
$temp=$matchContent[1][0];
else
$temp=$zbp->host."zb_users/theme/$theme/style/images/random/$temp.png";
{/php} 如果没有图片,我们就从在当前主题的/style/images/random/文件夹中调用5个准备好的png图片,名称分别是1.png,2.png,3.png,4.png,5.png。且如果需要多个我们可以修改上面的参数。 PS:以上代码放到调用文章列表循环内。 2、调用位置 代码如下
- 上一篇 : phpcms调用现上一篇下一篇文章调用例子
- 下一篇 : ZBLOG PHP调用最新文章、热门点击、最多用户评论