分享给需要的朋友,在function.php 加上下段代码,最后在模板中使用
<?php showThumbnail($this); ?>调用就可以了。
代码如下:
/* 输出文章缩略图 /
function showThumbnail($widget) {
$attach = $widget->attachments(1)->attachment;
$pattern = '/\<img.?src\=\"(.?)\"1*>/i';
if (preg_match_all($pattern, $widget->content, $thumbUrl)) {
echo $thumbUrl1;
} else
if ($attach->isImage) {
echo $attach->url;
} else {
echo $random;
} }
到此结束。
- > ↩