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

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

Typecho维基君开发日志 • 754次浏览 • 发布 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头像,如果无就调用随机或者固定头像

厂商投放

【腾讯云】爆款2核2G云服务器首年40元 首购最高获赠300元京东卡

腾讯云双十一采购节,云服务器多种机型限时抢购,2核2G首年40元,4核8G首年211元,专业技术7*24小时在线服务,腾讯云为企业和个人提供快捷,安全,稳定的云服务!

广告
添加新评论 »

仅有一条评论 »

  1. [...]之前是可以显示出来的,正常情况只要去Gravatar官网邮箱注册并上传头像,然后使用就是官网的或者镜像源站+/avatar/邮箱的md5就可以访问了。你可能感兴趣Typecho干掉慢死的gravatar,用QQ头像和随机或者固定头像代替Typecho Gravatar头像镜像源修改教程,解决头像不显示问题通过QQ邮箱获取并显示头像【不暴露QQ号】Typecho 修改默认评论头像以及Gravatar[...]