Gravatar :有默认图像吗?
我已经为正在构建的门户实现了 gravatar,并且想知道 gravatar 是否有默认图像 URL?并非所有访问该网站的人都已登录或拥有电子邮件地址,在这种情况下,是否有可以显示的默认图像(可通过 gravatar url 访问)
I have implemented gravatar for a portal I am building and wanted to know if there is a default image URL for gravatar? Not all people who visit the site are logged in or have email addresses, in such a case, is there a default image that can be shown (accessible via gravatar url)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
要选择默认图像,您可以使用
d
参数:或不使用哈希:
或不使用
d
参数:来源:gravatar.com。
To select a default image, you can use the
d
parameter:Or without a hash:
Or without the
d
parameter:Source: gravatar.com.
Gravatar 在此处描述了默认图像的选项:http://en.gravatar.com/site/implement /images/
您可以通过将适当的名称/值对添加到您的网址来选择您想要的选项。例如,您可以使用“神秘人”(d=mp),如下所示:
上面的图像是使用以下命令创建的网址
http://www.gravatar.com/avatar/?d=mp
。请注意,电子邮件哈希字符串已被省略,但通常您会将其包含在请求中。上述链接中列出的选项:
如您所愿,也可以使用尺寸选项
s=
更改默认图像的大小。上面的图像是使用
http://www.gravatar.com/avatar/? 创建的d=retro&s=32
感谢 @Alireza Rezaee 更新了图像类型。
Gravatar describe the options for default images here: http://en.gravatar.com/site/implement/images/
You can select which option you want by adding the appropriate name/value pair to your url. For example, you could use "mystery person" (d=mp) which looks like this:
The above image was created with the url
http://www.gravatar.com/avatar/?d=mp
. Note that the email hash string has been omitted but normally you would include it as part of the request.Options listed at the above link:
As you would hope, using the size option
s=<pixels>
also changes the size of the default image.The above image was created with
http://www.gravatar.com/avatar/?d=retro&s=32
Thanks to @Alireza Rezaee for the updated image types.
您还可以使用默认/后备头像的自定义 URL。但是,自定义 URL 必须指向公开可用的图像,否则将不会显示。您可以在此处和gravatar.com。
这是我在处理头像图像时使用的 PHP 函数。
用法示例:
You can also use a custom URL for the default/fallback avatar. However, the custom URL must point to a publicly available image or else it wont show. You can learn more here and at gravatar.com.
Here is a PHP function I use to when working with gravatar images.
Example usage:
不完全是,不。这没有抓住 Gravatar 服务的重点。它的设计目的是让您的用户可以注册他们的电子邮件地址并将头像图像与其相关联。然后,您的网站(和其他网站)可以查询 Gravatar 以返回与相关电子邮件地址关联的图像。
如果您希望向甚至不在您的网站上输入电子邮件地址的用户显示图像,我可以看到两种解决方案:
[email] ;受保护]< /code> 然后将其注册到 Gravatar 服务并将您选择的默认图像与其关联。在构建图像 URL 时,您自己的应用程序代码仍然需要输出适当的头像 URL,以替换此电子邮件地址来代替用户不存在的电子邮件地址,但它将允许您使用您所要求的头像 URL。
Not really, no. That is missing the point of the Gravatar service. It is designed so that your users can register their email address(es) and associate a gravatar image with it/them. Your site (and other sites) can then query Gravatar to give back the image which is associated with the email address in question.
If you want an image showing for users who do not even enter an email address on your website, you have two solutions that I can see:
[email protected]
and then register this with the Gravatar service and associate your chosen default image with this. Your own app code will still need to output the appropriate gravatar URL substituting this email address in place of the user's non-existant one when constructing the image URL, but it will allow you to use a gravatar URL which is something you have asked for.对于那些只想链接到给定电子邮件图像的人(这并不能解决 OP 的请求,但此页面在网络搜索中很突出):从几乎任何 POSIX shell,您都可以为“[email protected]" 为:
您确实需要考虑足够多的内容来替换 [email protected] 包含有问题的电子邮件。我添加了“?s=256”来展示如何指定大小。
我需要这个来向某人说明什么是头像。
For those who just want a link to a given email's image (this does not address the OP's request, but this page is prominent in web searches): From almost any POSIX shell you can generate the 256 pixel gravatar URL for "[email protected]" with:
You do need to think enough to replace [email protected] with the email in question. I included the "?s=256" to show how to specify the size.
I needed this to illustrate to somebody what a gravatar is.