As regards showing them automatically with Gravatar, here is the answer I posted here:
The 'random' colorful gravatars are displayed because this query string parameter is being added to every gravatar source url:
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:
PS: This is the url used for the example: https://www.gravatar.com/avatar/94d093eda664addd6e450d7e9881bcad?s=32&d=identicon&r=PG
Btw, these images (called Identicons) are not really random, but are generated based on a Hash of your IP address.