Loading... ## 介绍 当我们在很多博客或者网站留言,评论的时候会看到有的人头像很酷很个性化,但是这个博客和网站本身并没有提供设置头像的功能,感觉有点神奇,那么是怎么做到的呢?其实这是使用了Gravatar。 Gravatar,全称Globally Recognized Avatar。翻译成中文为`全球通用头像`。 Gravatar的概念首先是在国外的独立WordPress博客中兴起的,当你到任何一个支持Gravatar的网站留言时,这个网站都会根据你所提供的Email地址为你显示出匹配的头像。当然,这个头像,是需要你事先到Gravatar的网站注册并上传的,否则,在这个网站上,就只会显示成一个默认的头像。 当你访问支持gravatar头像的网站时,只要输入你注册的邮箱账号,即会自动调用gravatar的api,转换成保存的头像。这样就可以为广大程序提供个人头像存储服务。 ## 使用 使用该服务时需要去[官网](https://cn.gravatar.com/)中注册一个账号,并上传头像。 注意头像上传后会审核,然后管理员会按图片包含的内容划分一个等级(G 普通级、PG 辅导级、R 和 X 为限制级)。 通过之后这个头像就可以使用了。在任何支持Gravatar的地方,在评论填写email地址时,请填写你申请注册头像用的这个email地址。你的头像就会出现在留言中。就这样可以展示给大家看了 ## 调用 由于gravatar目前服务极不稳定,调用时推荐用国内的源。 换源方法:一般在模板文件的`functions.php`文件中,搜索gravatar,把搜索到的域名直接替换掉即可,handsome主题可在主题设置中修改。 本站使用的是自建的镜像源。`gravatar.zeruns.tech/avatar/` 我的自建镜像源境内使用了[腾讯云](https://cloud.tencent.com/act/cps/redirect?redirect=1040&cps_key=69aab81d20a9e10e5ad56107d5303535&spread_hash_key=382044a678827f5a526f5a6ee9b2925e&from=console)CDN,境外使用Cloudflare CDN,欢迎大家使用。 以下个人整理备份。 - Zeruns's Blog的源:[https://gravatar.zeruns.tech/avatar/](https://gravatar.zeruns.tech/avatar/) - ~~宝硕博客的源:[https://gravatar.baoshuo.ren/avatar](https://gravatar.baoshuo.ren/avatar)~~ - gravatar官方的www源 [https://www.gravatar.com/avatar/](https://www.gravatar.com/avatar/) - gravatar官方的cn源 [https://cn.gravatar.com/avatar/](https://cn.gravatar.com/avatar/) - gravatar官方的en源 [https://en.gravatar.com/avatar/](https://en.gravatar.com/avatar/) - gravatar官方的secure源 [https://secure.gravatar.com/avatar/](https://secure.gravatar.com/avatar/) - V2EX源 [https://cdn.v2ex.com/gravatar/](https://cdn.v2ex.com/gravatar/) - Loli源 [https://gravatar.loli.net/avatar/](https://gravatar.loli.net/avatar/) - 极客族 [https://sdn.geekzu.org/avatar/](https://sdn.geekzu.org/avatar/) 不过当然,有兴趣的同学可以自建镜像。可以利用Nginx反代`https://www.gravatar.com/`这个域名,然后就可以用你自己的域名访问啦。 以上部分介绍整理自百度百科:[https://baike.baidu.com/item/Gravatar/10996811](https://baike.baidu.com/item/Gravatar/10996811) ## 推荐文章 - 高性价比和便宜的VPS/云服务器推荐:[https://blog.zeruns.tech/archives/383.html](https://blog.zeruns.tech/archives/383.html) - CDN推荐:[https://blog.zeruns.tech/archives/386.html](https://blog.zeruns.tech/archives/386.html) - 怎样搭建个人博客:[https://blog.zeruns.tech/archives/218.html](https://blog.zeruns.tech/archives/218.html) - 各大云服务器厂商618活动优惠大全:[https://blog.zeruns.tech/archives/549.html](https://blog.zeruns.tech/archives/549.html) - 使用WebP节省网站流量和存储空间,加快网站加载速度:[https://blog.zeruns.tech/archives/547.html](https://blog.zeruns.tech/archives/547.html) 最后修改:2021 年 02 月 27 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果您觉得我的文章有帮助,请随意赞赏,赞赏有助于激发博主的热情,感谢!
12 条评论
谢谢大佬分享
https://blog.pho.ink/archives/1023.html
添加下这个资源吧,谢谢
现在好像不可以使用CDN直接回源了吗?好像是www secure cn 0 1这些前缀域名都被墙了
,博主用的是反向代理吗
感谢dalao分享!!!现在现在加载头像比用v2ex快了不少,改天我也自建一个。
functions.php打不开怎么办?
这个文件加密了,加密方式好像是mzphp,你网上搜一下有解密的平台,解密了不要传播,尊重版权
谢谢大佬分享,学到了!
我自己也建了一个,教程:https://blog.baoshuo.ren/archives/61.html ,镜像源查看地址:https://blog.baoshuo.ren/apilist.html (有CDN)
可不可以加一下呀大佬
你的gravatar镜像现在好像失效了
被人搞炸了,不搞了
新博客欢迎来访:https://blog.baoshuo.ren/ ヾ(≧∇≦*)ゝ
加上了 ::BZ:33_hecha::
谢谢大佬分享,学到了!