如果大家访问过基于Chevereto搭建的图床,可能会看到一些图床的首页有托管图片的数量统计,通过查询,找到了实现方式,特记录在此,方便自己后期查询也方便有此需求的你。

修改首页代码

修改 index.php 文件,位置:/chevereto/app/themes/Peafowl/views/index.php,找到下述代码:

<div class="home-buttons">
    ......
</div>

在下面添加下述代码:

<p id="home-cover-msg">
    <?php echo CHV\getSetting('homepage_paragraph_html') ?: _s('<span class=\'image-count\'>%s</span> images hosted', get_totals()['images'] > 999999 ? get_totals_display()['images'] : number_format(get_totals()['images'])); ?>
</p>

修改后台代码

修改 route.index.php 文件,位置:/chevereto/app/routes/route.index.php,找到下述代码:

$handler::setVar('doctitle', CHV\Settings::get('website_doctitle'));
$handler::setVar('pre_doctitle', CHV\Settings::get('website_name'));

在此后添加代码:

$handler::setVar('totals', CHV\Stat::getTotals());

通过以上两步即可实现。

Last modification:May 4, 2022
您的打赏,将全部用于服务器购置及域名续费等,以保证诸如跬步图床等的免费服务