Skip to content

Instantly share code, notes, and snippets.

@ahmagdy
Last active April 6, 2018 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmagdy/8cf2f5fcc545c17b079c43a37389d718 to your computer and use it in GitHub Desktop.
Save ahmagdy/8cf2f5fcc545c17b079c43a37389d718 to your computer and use it in GitHub Desktop.
Get Gravatar Image From Email
import crypto from 'crypto';
export const getGravatarFromEmail = (email, size) => {
if (!email) return;
const hash = crypto.createHash('md5').update(email).digest('hex');
let returnedUrl = `https://www.gravatar.com/avatar/${hash}`;
if (!size || size < 1) return returnedUrl;
returnedUrl += `?s=${size}`;
return returnedUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment