How to generate the random default "gravatars" like on Stack Overflow?
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:
Yet, the same URL with the d=identicon
parameter included, shows this:
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.
Related videos on Youtube
Dávid Kertész
Updated on January 29, 2020Comments
-
Dávid Kertész over 4 years
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?
-
Ilmari Karonen almost 10 yearsNote: The question this was originally closed as a duplicate of has been migrated to Meta Stack Exchange, but IMO this remains a valid question for Stack Overflow, too. I have thus cleaned it up and voted to reopen it.
-
-
Dávid Kertész about 15 yearsHi, is there an example of an implementation I could swipe for Ruby on Rails?
-
Andreas Grech about 15 yearsCheck out these links: douglasfshearer.com/blog/gravatar-for-ruby-and-ruby-on-rails | slightlycoded.com/blog/…
-
Cyril N. over 10 years* "a geometric pattern based on an email hash", not the IP Address hash (source: fr.gravatar.com/site/implement/images )