@register.simple_tag(takes_context=True)
def avatar_url(context, user, size, resolution=u'1x', service_id=None):
 if (resolution not in (u'1x', u'2x')):
  raise ValueError((u'resolution should be "1x" or "2x", not %r.' % resolution))
 service = avatar_services.for_user(user, service_id)
 if (service is None):
  logging.error(u'Could not get a suitable avatar service for user %s.', user)
  return mark_safe(u'')
 urls = service.get_avatar_urls(request=context[u'request'], user=user, size=size)
 return urls[resolution]

@ register . simple_tag ( takes_context = True ) def avatar_url ( context , user , size , resolution = u'1x' , service_id = None ) : if ( resolution not in ( u'1x' , u'2x' ) ) : raise ValueError ( ( u'resolution should be "1x" or "2x", not %r.' % resolution ) ) service = avatar_services . for_user ( user , service_id ) if ( service is None ) : logging . error ( u'Could not get a suitable avatar service for user %s.' , user ) return mark_safe ( u'' ) urls = service . get_avatar_urls ( request = context [ u'request' ] , user = user , size = size ) return urls [ resolution ]
return the url of the requested avatar .