How to generate the random default “gravatars” like on Stack Overflow?

后端 未结 1 1404
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 16:57

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 avat

相关标签:
1条回答
  • 2020-12-23 17:24

    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: alt text

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

    This is the URL used for the example: https://www.gravatar.com/avatar/94d093eda664affffd6e450d7e9881bcad?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.

    0 讨论(0)
提交回复
热议问题