Created
August 10, 2013 05:12
-
-
Save alexlovelltroy/6199146 to your computer and use it in GitHub Desktop.
generate a gravatar image url from an e-mail address
This file contains 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 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