Typecho 获取文章图片数量代码
在你的博客主题functions.php里面增加下面函数:
function imgNum($content){
$output = preg_match_all("/<img.<em>?src="(.</em>?)"<sup id="fnref-1"><a href="#fn-1" class="footnote-ref">1</a></sup>*>/i", $content,$matches);
$cnt = count( $matches[1] );
return $cnt;
}
在你想显示的地方调用方法:
<?php echo ''.imgNum($this->content).'' ; ?>