Typecho修改Gravata头像源
AI摘要 文章介绍了如何在Typecho中修改Gravatar头像源,以解决境内访问Gravatar服务器不稳定的问题。提供了修改Common.php文件中gravatarUrl代码的方法,将默认的头像源地址替换为国内的头像源地址。
前言
Gravatar的全称是:Globally Recognized Avatar,指的是“全球通用头像”。在Gravatar的服务器上设置了你自己的头像,那么在任何支持Gravatar的博客或者留言本上评论时,只要提供你与这个头像关联的邮箱地址,就可以展示你在Gravatar上设置的头像来。
Typecho 也是默认有支持 Gravatar 头像功能的
由于 Gravatar 境内经常访问不了,所以在这里做一下记录。
方法
- 找到网站目录:
/var/Typecho下的Common.php文件 - 搜索:gravatarUrl,找到如下代码:
$url = $isSecure ? 'https://cdn.helingqi.com' : 'http://www.gravatar.com';
把默认的两个地址换为国内的头像源:
$url = $isSecure ? 'https://fdn.geekzu.org' : 'https://gravatar.zeruns.tech';
或:$url = $isSecure ? 'https://cdn.v2ex.com/gravatar' : 'https://cdn.v2ex.com/gravatar';
当然如果上下两行合并的话,加上路径即可
$url = $isSecure ? 'https://fdn.geekzu.org/avatar/' : 'https://gravatar.zeruns.tech/avatar/';
完整代码
public static function gravatarUrl(
?string $mail,
int $size,
?string $rating = null,
?string $default = null,
bool $isSecure = true
): string {
if (defined('__TYPECHO_GRAVATAR_PREFIX__')) {
$url = __TYPECHO_GRAVATAR_PREFIX__;
} else {
// $url = $isSecure ? 'https://secure.gravatar.com' : 'http://www.gravatar.com';
$url = $isSecure ? 'https://fdn.geekzu.org' : 'https://gravatar.zeruns.tech';
$url .= '/avatar/';
} - 上一篇:没有了
- 下一篇:Typecho在评论增加IP归属地址展示
欢迎加入 Typecho 大家族
1212
2323