Skip to content

Instantly share code, notes, and snippets.

@alexlovelltroy
Created August 10, 2013 05:12
Show Gist options
  • Save alexlovelltroy/6199146 to your computer and use it in GitHub Desktop.
Save alexlovelltroy/6199146 to your computer and use it in GitHub Desktop.
generate a gravatar image url from an e-mail address
import hashlib
def generate_avatar_url(addr, size):
default = 'mm'# or '404' or 'blank'
gravatar_base_url = 'http://www.gravatar.com/avatar/'
computed_hash = hashlib.md5(str(addr).lower().lstrip().rstrip()).hexdigest()
return '%s%s?d=%s&s=%s' % (gravatar_base_url, computed_hash, default, size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment