Bash
{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
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

微信扫码关注
更新实时通知