Helix Swarm Guide (2018.3)

Avatars

Swarm uses avatars, images that represent users and groups responsible for events in activity streams, projects, reviews, etc.

Avatars are retrieved from an avatar provider; the default provider is gravatar.com. Swarm sends an identifier to the avatar provider (for gravatar.com, an MD5 hash of the user's or group's email address), and the provider returns the configured image (if one exists). If no avatar is defined with the provider or the requests fails for any reason, Swarm selects an avatar from its internal collection.

You configure the avatar lookups with the avatars configuration block in the SWARM_ROOT/data/config.php file. Here is an example:

<?php
// this block should be a peer of 'p4'
'avatars' => array( 'http_url' => 'http://www.gravatar.com/avatar/{hash}?s={size}&d={default}',
'https_url' => 'https://secure.gravatar.com/avatar/{hash}?s={size}&d={default}',
),

Both http_url and https_url specify URLs that should be used instead of the default gravatar.com URLs. Swarm picks which URL to use based on the current request; for HTTPS requests, Swarm picks the https_url URL. If the picked URL is not defined, Swarm will use gravatar.com.

Several replacement values are available for inclusion in the URLs:

  • {user}

    The current Swarm userid, Perforce groupid, or empty string

  • {email}

    The current Swarm user's or group's email address, or empty string

  • {hash}

    The MD5 hash of the Swarm user's or group's email address, or 00000000000000000000000000000000 if no email address is configured

  • {default}

    The value blank for a transparent GIF (allowing users or groups without avatars to fallback to Swarm's internal avatars) or the value mm for a mystery man used in circumstances where no user or group identifier is known

  • {size}

    the size Swarm would like in pixels for both the width and height, without units, e.g. 64

The URL you specify must include one of {user}, {email}, or {hash} to properly select a user-specific or group-specific avatar. The URL should include {size} to assist Swarm's presentation. {default} is not necessary, but helps provide a consistent avatar experience.

Note

By default, gravatar.com serves only G-rated avatar images. If your Swarm users and groups wish to use PG-, R-, or X-rated images, you need to configure the avatar lookup URLs with the appropriate rating flag. For example, to allow avatars with G or PG ratings, the configuration would look like:

<?php
// this block should be a peer of 'p4'
'avatars' => array(
'http_url' => 'http://www.gravatar.com/avatar/{hash}?r=pg&s={size}&d={default}',
'https_url' => 'https://secure.gravatar.com/avatar/{hash}?r=pg&s={size}&d={default}',
),

For more information on gravatar.com image requests, see: https://en.gravatar.com/site/implement/images

Disable avatar lookups

If you wish to disable avatar lookups altogether and simply use Swarm's internal avatars, set each URL to '' (empty string). For example:

<?php
// this block should be a peer of 'p4'
'avatars' => array(
'http_url' => '',
'https_url' => '',
),