Last active
April 6, 2018 20:05
-
-
Save ahmagdy/8cf2f5fcc545c17b079c43a37389d718 to your computer and use it in GitHub Desktop.
Get Gravatar Image From Email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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