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).'' ; ?>
如若转载,请注明出处:https://www.ozabc.com/jianzhan/7437.html