Typecho默认头像来自Gravatar,没设置过头像就非常的丑,但是又不想注册Gravatar,就想替换为QQ头像。
修改Typecho目录下的var/Typecho/common.php,在大约932行,关于获取Gravatar的代码,修改为:
public static function gravatarUrl($mail, $size, $rating, $default, $isSecure = false)
{
$reg = "/^\d{5,11}@[qQ][Qq]\.(com)$/";
if (preg_match($reg, $mail)) {
$img = explode("@", $mail);
$url = "//q2.qlogo.cn/headimg_dl?dst_uin={$img[0]}&spec=100";
} else {
if (defined('__TYPECHO_GRAVATAR_PREFIX__')) {
$url = __TYPECHO_GRAVATAR_PREFIX__;
} else {
$url = $isSecure ? 'https://secure.gravatar.com' : 'http://www.gravatar.com';
$url .= '/avatar/';
}
if (!empty($mail)) {
$url .= md5(strtolower(trim($mail)));
}
$url .= '?s=' . $size;
$url .= '&r=' . $rating;
$url .= '&d=' . $default;
}
return $url;
}
Pages: 1 2
Comments | NOTHING