zblog获取文章的所有图片作为缩略图代码

时间:4年前   阅读:5425

{php}
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
$content = $article->Content;
preg_match_all($pattern,$content,$matchContent);
{/php}                  
{foreach $matchContent[1] as $img }
<a class="listimg" href="{$article.Url}">
    <img title="{$article.Title}" alt="{$article.Title}" src="{$img}" width="200" height="130">
</a>
{/foreach}

这个方法是获取文章中所有的图片,如果没有图片则不显示。

本站声明:网站内容来源于网络,如有侵权,请联系我们https://www.qiquanji.com,我们将及时处理。

微信扫码关注

更新实时通知

上一篇:PHP和web开发相关字符串函数

下一篇:2020年3月3日沪深股市交易提示

网友评论

请先 登录 再评论,若不是会员请先 注册