Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a url of a GRAVATAR image from a given email

Tags:

php

gravatar

There is a simple way with php, a simple script or URL manipulation to build a URL for the gravatar image corresponding to an email?

Ex. http://gravatar.com/avatars/[email protected] and this return a jpeg or png image.

If there is no simple way like the example, what is the easiest way you know to resolve a url of the gravatar corresponding to an email?. Thanks

like image 809
DomingoSL Avatar asked Apr 27 '10 05:04

DomingoSL


People also ask

How do I find my Gravatar URL?

This URL enables you to link to a Gravatar image using the encoded email address of the Gravatar account. However, you need to MD5 hash the email address for the Gravatar account to get the hash. All Gravatar URL's are based on the use of the hashed value of an email address.

How do I find someone's Gravatar?

Gravatar Profile Search – Search for Gravatar by Email If you want to look up your own Gravatar image (or someone else's image), there's a Gravatar profile search feature that lets you look up someone's profile picture by entering their email address.

What is a Gravatar ID?

What is Gravatar? Gravatar is a free service used to manage one's avatars on the web and allows Internet users to have “an effortless and verified way to establish their identity online”, as stated on its official website. Websites and other services can use these avatars to “humanize” their platforms a little more.


2 Answers

The root script is at http://www.gravatar.com/avatar/ The next part of the URL is the hexadecimal MD5 hash of the requested user's lowercased email address with all whitespace trimmed. You may add the proper file extension, but it's optional.

The complete API is here http://en.gravatar.com/site/implement/

like image 50
Mikulas Dite Avatar answered Oct 04 '22 18:10

Mikulas Dite


Use this:

$userMail = whatever_to_get_the_email;

$imageWidth = '150'; //The image size

$imgUrl = 'http://www.gravatar.com/avatar/'.md5($userMail).'fs='.$imageWidth;
like image 36
dipi evil Avatar answered Oct 04 '22 19:10

dipi evil