有没有办法可以提取内容中的图片作为缩略图?
怎么实现呢??
有没有办法可以提取内容中的图片作为缩略图?
Re: 有没有办法可以提取内容中的图片作为缩略图?
暂时实现起来有点困难……
Re: 有没有办法可以提取内容中的图片作为缩略图?
使用正则取出,在模板里修改
http://www.cnvato.cn/
thumb.php为一个缩略图处理类。
我的博客
http://www.cnvato.cn/
代码: 全选
<?php
preg_match_all( "/<img.*?src="(.*?)"[^>]*>/i", $this->content, $thePics );
$allPics = count($thePics[0]);
switch ( $allPics > 0 ) {
case $allPics = 1:
$imgcover=$this->options->themeUrl."/thumb.php?src=".$thePics[1][0]."&h=57&w=100&zc=1&q=90";
echo "<img src="$imgcover"/>" ;
break;
default:
echo "<img src="".$this->options->themeUrl."/images/noimage.jpg" />";
};
?>
thumb.php为一个缩略图处理类。
我的博客