首页 期权学习期权知识正文

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

xiaojiucai 期权知识 2020-08-18 434 0
{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/post/7094.html

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

微信扫码关注

更新实时通知

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

评论