@register.simple_tag
def get_gravatar(email, size=80, rating='g', default=None, protocol=PROTOCOL):
 gravatar_protocols = {'http': 'http://www', 'https': 'https://secure'}
 url = ('%s.gravatar.com/avatar/%s' % (gravatar_protocols[protocol], md5(email.strip().lower().encode('utf-8')).hexdigest()))
 options = {'s': size, 'r': rating}
 if default:
  options['d'] = default
 url = ('%s?%s' % (url, urlencode(options)))
 return url.replace('&', '&amp;')

@ register . simple_tag def get_gravatar ( email , size = 80 , rating = 'g' , default = None , protocol = PROTOCOL ) : gravatar_protocols = { 'http' : 'http://www' , 'https' : 'https://secure' } url = ( '%s.gravatar.com/avatar/%s' % ( gravatar_protocols [ protocol ] , md5 ( email . strip ( ) . lower ( ) . encode ( 'utf-8' ) ) . hexdigest ( ) ) ) options = { 's' : size , 'r' : rating } if default : options [ 'd' ] = default url = ( '%s?%s' % ( url , urlencode ( options ) ) ) return url . replace ( '&' , '&amp;' )
return url for a gravatar .