Avatars
Swarm uses avatars, images that represent users 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 email address), and the provider returns the
user's configured image (if one exists). If the requests fails for any
reason, Swarm selects an avatar from its internal bee-themed collection.
You configure the avatar lookups with the avatars
configuration block in the
file. Here is an example:
SWARM_ROOT
/data/config.php
<?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, or empty string
-
{email}
-
The current Swarm user's email address, or empty string
-
{hash}
-
The MD5 hash of the Swarm user's email address, or
00000000000000000000000000000000
if no email address is configured -
{default}
-
The value
blank
for a transparent GIF (allowing users without avatars to fallback to Swarm's internal bee-themed avatars) or the valuemm
for a mystery man used in circumstances where no user 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 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 wish to use PG-, R-, or X-rated images, you'll
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
's 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 bee-themed avatars, set each URL to
false
. For example:
<?php
// this block should be a peer of 'p4'
'avatars' => array(
'http_url' => false,
'https_url' => false,
),