如何生成随机的默认"gravatars".像在堆栈溢出? [英] How to generate the random default "gravatars" like on Stack Overflow?

查看:67
本文介绍了如何生成随机的默认"gravatars".像在堆栈溢出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于那些没有上传图片或没有创建Gravatar图标的用户,Stack Overflow如何自动生成gravatars?

How does Stack Overflow auto-generate the gravatars for those users who do not upload a picture or who have not created a Gravatar icon?

这些随机化身来自哪里,如何为自己的网站生成它们?

Where do these random avatars come from, and how can I generate them for my own site?

推荐答案

显示随机"的彩色gravatars,因为此查询字符串参数已添加到每个gravatar源URL:d=identicon

The 'random' colorful gravatars are displayed because this query string parameter is being added to every gravatar source URL: d=identicon

这样做是为了,如果用户没有与他的电子邮件关联的图像,则显示此随机"图像,而不是默认的蓝色图像.

This is done so that if the user doesn't have a gravatar image associated with his email, this 'random' image is displayed, instead of the default blue gravatar image.

由于不包含该参数,因此以下显示默认"蓝色图像:

The following displays the 'default' blue image because the parameter is not included:

但是,包含了d=identicon参数的相同URL显示如下:

Yet, the same URL with the d=identicon parameter included, shows this:

这是示例使用的URL:https://www.gravatar.com/avatar/94d093eda664addd6e450d7e9881bcad?s=32&d=identicon&r=PG

This is the URL used for the example: https://www.gravatar.com/avatar/94d093eda664addd6e450d7e9881bcad?s=32&d=identicon&r=PG

通过这些图像(称为图标)的方式并不是真正随机的,而是基于在电子邮件哈希上.

By the way these images (called Identicons) are not really random, but are generated based on the email hash.

请参见如何生成默认用户头像?该算法的某些语言实现.

See How is the default user avatar generated? for some Language Implementations of this algorithm.

这篇关于如何生成随机的默认"gravatars".像在堆栈溢出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆