<?php
preg_match_all("/\<img.*?src\=(\'|\")(.*?)(\'|\")[^>]*>/i", $this->content, $matches);
$imgCount = count($matches[0]);
if($imgCount >= 1){
$img = $matches[2][0];
echo <<<Html
<p class="post-images">
<a href="{$this->permalink}" title="{$this->title}">
<img src="{$img}" alt="{$this->title}">
</a>
</p>
Html;
}
?>自动调用第1个文章图片。
评论已关闭