比尔盖子 博客

轻松解决 WordPress 头像被墙无法显示的问题

Gravatar头像是“Globally Recognized Avatar 全球识别头像”的缩写,他可以让你留言时显示的头像绑定你的常用Email地址,使你不论在哪里留言,都将使用你设定好的Gravatar头像。

而Wordpress的头像全部取自Gravatar的服务器,这就是为什么头像显示慢了。

但是,Gravatar部分服务器长期被墙,我的Wordpress升级到3.0.1后就出现了这样的问题,今天刚刚解决。

找到wp-includes/pluggable.php文件的大约1645行,只要将:

if ( is_ssl() ) {
 $host = ‘https://tomli.blog/gravatar’;
}
 else {
if ( !empty($email) )
 $host = sprintf(“http://%d.gravatar.com”, ( hexdec( $email_hash{0} ) % 2 ) );
 else $host = ‘http://0.gravatar.com’;
}

修改为:

if ( is_ssl() )
 $host = 'https://tomli.blog/gravatar';
 else
 $host = 'http://www.gravatar.com';

就可以了。

原理其实很简单,在Wordpress 3.0.1中,为了加快头像载入的速度,Wordpress会自动判断使用哪台Gravatar的分流服务器。

这本是一个不错的功能,但是Gravatar的副服务器大部分被墙。

但主服务器www.Gravatar.com没有被墙,所以改为从主服务器上获取头像(Wordpress 2.9.2 使用的方法)后恢复正常,但不知道那天会被墙呢。

附:

Gravatar头像的申请方法如下:

1.猛击这里,填写注册邮箱之后,点击”Signup”按钮;

2.到注册的邮箱中查收邮件并点击其中的链接确认;

3.在弹出页面中填写相关内容;

4.点击页面中部框框下的链接”Add one by clicking here!”;

5.如果要从自己的本地硬盘上传一张头像,那就点击第一个链接”My computer’s hard drive”上传头像;

6.进入Crop页面,滑动滑块选择你需要的照片区域后点击页面下部的”CROP”按钮;

7.给自己的头像评定级别。G 普通级、PG 辅导级、R 和 X 为限制级,一般不黄不暴力的选G就行了;

8.点击页面中的头像照片,在弹出的小页面里点击”Confirm”钮确认;

9.到支持Gravatar头像功能的网站发表评论试试吧,要想改头像的话只需要到http://en.gravatar.com/网站里登陆后修改即可。

Categories: GFW, 建站那点事

巧用GFW,瞬间判断网站在国内还是国外 » « Akismet,垃圾评论的克星

3 Comments

  1. 今天又无法显示了,试试看~!

发表评论

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Copyright © 2023 比尔盖子 博客

Theme by Anders NorenUp ↑