@library.global_function
def profile_avatar(user, size=48):
 try:
  profile = Profile.objects.get(user_id=user.id)
 except (Profile.DoesNotExist, AttributeError):
  avatar = (settings.STATIC_URL + settings.DEFAULT_AVATAR)
 else:
  avatar = (profile.avatar.url if (profile and profile.avatar) else (settings.STATIC_URL + settings.DEFAULT_AVATAR))
 if avatar.startswith('//'):
  avatar = ('https:%s' % avatar)
 if (user and hasattr(user, 'email')):
  email_hash = hashlib.md5(force_str(user.email.lower())).hexdigest()
 else:
  email_hash = '00000000000000000000000000000000'
 url = ('https://secure.gravatar.com/avatar/%s?s=%s' % (email_hash, size))
 if avatar.startswith('http'):
  url = (url + ('&d=%s' % urllib.quote(avatar)))
 return url

@ library . global_function def profile_avatar ( user , size = 48 ) : try : profile = Profile . objects . get ( user_id = user . id ) except ( Profile . DoesNotExist , AttributeError ) : avatar = ( settings . STATIC_URL + settings . DEFAULT_AVATAR ) else : avatar = ( profile . avatar . url if ( profile and profile . avatar ) else ( settings . STATIC_URL + settings . DEFAULT_AVATAR ) ) if avatar . startswith ( '//' ) : avatar = ( 'https:%s' % avatar ) if ( user and hasattr ( user , 'email' ) ) : email_hash = hashlib . md5 ( force_str ( user . email . lower ( ) ) ) . hexdigest ( ) else : email_hash = '00000000000000000000000000000000' url = ( 'https://secure.gravatar.com/avatar/%s?s=%s' % ( email_hash , size ) ) if avatar . startswith ( 'http' ) : url = ( url + ( '&d=%s' % urllib . quote ( avatar ) ) ) return url
return a url to the users avatar .