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.

Tip

If you make a configuration change, Swarm will not use it until the configuration cache has been reloaded, this forces Swarm to use the new configuration. You must be an admin or super user to reload the Swarm config cache. Navigate to the User id dropdown menu, select System Information, click the Cache Info tab, and click the Reload Configuration button.

Configure the avatar lookups in 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}',
),
  • http_url: specifies the http URL Swarm uses to lookup avatars. If the URL is not defined, Swarm uses the default gravatar.com URL.
  • https_url: specifies the https URL Swarm uses to lookup avatars. If the URL is not defined, Swarm uses the default gravatar.com URL.

The avatars array URL that Swarm uses depends on the settings of the Swarm Apache server protocol and the external_url protocol, the securest of these protocols is used.

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.

Tip

You can adjust the appearance of avatars by using custom CSS, see Adjust the appearance of avatars.

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' => '',
),