Avatars

P4 Code Review 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. P4 Code Review 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, P4 Code Review selects an avatar from its internal collection.

If you make a configuration change, P4 Code Review will not use it until the configuration cache has been reloaded, this forces P4 Code Review to use the new configuration. You must be an admin or super user to reload the P4 Code Review 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 P4 Code Review uses to lookup avatars. If the URL is not defined, P4 Code Review uses the default gravatar.com URL.
  • https_url: specifies the https URL P4 Code Review uses to lookup avatars. If the URL is not defined, P4 Code Review uses the default gravatar.com URL.

The avatars array URL that P4 Code Review uses depends on the settings of the P4 Code Review 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 P4 Code Review userid, Perforce groupid, or empty string

  • {email}

    The current P4 Code Review user's or group's email address, or empty string

  • {hash}

    The MD5 hash of the P4 Code Review 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 P4 Code Review'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 P4 Code Review 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 P4 Code Review's presentation. {default} is not necessary, but helps provide a consistent avatar experience.

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

By default, gravatar.com serves only G-rated avatar images. If your P4 Code Review 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 Profiles as a Service.

Disable avatar lookups

If you wish to disable avatar lookups altogether and simply use P4 Code Review'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' => '',
),