Typecho Wiki
每一个作品都值得被记录

Typecho干掉慢死的gravatar,用QQ头像和随机或者固定头像代替

Typecho维基君Typecho教程 • 917次浏览 • 发布 2023-01-22 • 更新 2023-01-22
极致加速的V2Ray 助您畅享全球网络 & 搬瓦工VPS最新优惠码
🛜自用大流量超低月租手机卡推荐榜单 #拒绝流量焦虑

相关即可:
在当前主题的comment.php文件中找到 <?php $comments->gravatar('40','','','fl'); ?>,并将其替换为以下代码:

<span itemprop="image">
<?php $number=$comments->mail;
if(preg_match('|^[1-9]\d{4,11}@qq\.com$|i',$number)){
echo '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$number.'&spec=100" width="46px" height="46px" style="border-radius: 50%;float: left;margin-top: 0px;margin-right: 10px;margin-bottom:-2px">'; 
}
else
{
$number=rand(1,1000);
echo '<img src="https://magicblue.cn/lostblue/image/'.$number.'.jpg" width="46px" height="46px" style="border-radius: 50%;float: left;margin-top: 0px;margin-right: 10px;margin-bottom:-2px">';
}
?>
</span>

如果要更换为固定头像

<span itemprop="image">
<?php $number=$comments->mail;
if(preg_match('|^[1-9]\d{4,11}@qq\.com$|i',$number)){
echo '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$number.'&spec=100" width="46px" height="46px" style="border-radius: 50%;float: left;margin-top: 0px;margin-right: 10px;margin-bottom:-2px">'; 
}
else
{
echo '<img src="https://magicblue.cn/xx.jpg" width="46px" height="46px" style="border-radius: 50%;float: left;margin-top: 0px;margin-right: 10px;margin-bottom:-2px">';
}
?>
</span>

上述表示就是有qq邮箱就换qq头像,如果无就调用随机或者固定头像

广告声明:文内含有的对外跳转链接(包括不限于超链接、二维码、口令等形式),用于传递更多信息,节省甄选时间,结果仅供参考,Typecho.Wiki所有文章均包含本声明。
厂商投放

【腾讯云】🎉五一云上盛惠!云服务器99元/月续费同价!

腾讯云五一劳动节海量产品 · 轻松上云!云服务器首年1.8折起,买1年送3个月!超值优惠,性能稳定,让您的云端之旅更加畅享。快来腾讯云选购吧!

广告
添加新评论 »