Skip to content

Instantly share code, notes, and snippets.

@lucasdavila
Last active July 7, 2021 01:06
Show Gist options
  • Save lucasdavila/1305723 to your computer and use it in GitHub Desktop.
Save lucasdavila/1305723 to your computer and use it in GitHub Desktop.
Gravatar em 3 linhas com python
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" />
# -*- 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)
@gilsondev
Copy link

Aumentou as linhas =P

@lucasdavila
Copy link
Author

@gilsondev :) verdade, inclui a linha options = ..., recebi uma sugestçao no twitter para poder enviar opções como alt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment