Jump to >

reviewboard.avatars.templatetags.avatars

avatar(context, user, size, service_id=None)[source]

Render the user’s avatar to HTML.

When the service_id argument is not provided, or the specified service is not registered or is not enabled, the user’s specified avatar service will be used for rendering instead.

Parameters:
  • context (django.template.Context) – The template rendering context.
  • user (django.contrib.auth.models.User) – The user whose avatar is to be rendered.
  • size (int) – The height and width of the avatar, in pixels.
  • service_id (unicode, optional) – The unique identifier of the avatar service to use. If this is omitted, or the specified service is not registered and enabled, the default avatar service will be used.
Returns:

The user’s avatar rendered to HTML, or an empty string if no avatar service could be found.

Return type:

django.utils.safestring.SafeText

avatar_url(context, user, size, resolution=u'1x', service_id=None)[source]

Return the URL of the requested avatar.

Parameters:
  • context (django.template.Context) – The template rendering context.
  • user (django.contrib.auth.models.User) – The user whose avatar is to be rendered.
  • size (int) – The height and width of the avatar, in pixels.
  • resolution (unicode, optional) – The resolution of the avatar. This should be one of '1x', for normal DPI, or '2x', for high DPI. This defaults to normal DPI.
  • service_id (unicode, optional) – The unique identifier of the avatar service to use. If this is omitted, or the specified service is not registered and enabled, the default avatar service will be used.
Returns:

The URL of the requested avatar, or an empty string if no avatar service could be found.

Return type:

django.utils.safestring.SafeText

avatar_urls(context, user, size, service_id=None)[source]

Serialize the user’s avatar URLs into a JavaScript object.

Parameters:
  • context (django.template.Context) – The template rendering context.
  • user (django.contrib.auth.models.User) – The user whose avatar URLs are to be serialized.
  • size (int) – The height and width of the avatar, in pixels.
  • service_id (unicode, optional) – The unique identifier of the avatar service to use. If this is omitted, or the specified service is not registered and enabled, the default avatar service will be used.
Returns:

The rendered JavaScript object.

Return type:

django.utils.safestring.SafeText