Last active
July 7, 2021 01:06
-
-
Save lucasdavila/1305723 to your computer and use it in GitHub Desktop.
Gravatar em 3 linhas com python
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
print gravatar_image_tag('[email protected]', 32, {'class' : 'avatar', 'alt' : 'your gravatar'}) | |
<img src="http://www.gravatar.com/avatar/3b4d33514d78047bf86307ab354658df?size=32" alt="your gravatar" class="avatar" /> |
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
# -*- coding: utf-8 -*- | |
import hashlib | |
def gravatar_image_tag(email, size = 48, options = {}): | |
options = ' '.join(["%s='%s'"%(k, options[k]) for k in options]) | |
return "<img src='http://www.gravatar.com/avatar/%s?size=%s' %s />"%(hashlib.md5(email.lower()).hexdigest(), size, options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gilsondev :) verdade, inclui a linha options = ..., recebi uma sugestçao no twitter para poder enviar opções como alt.