Hi!请登陆

Typecho如何获取文章图片数量?

2020-10-19 47 10/19

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).'' ; ?>

Tag:

相关推荐