Typecho主题插件站
每一个作品都值得被记录

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

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

厂商投放
添加新评论 »