Adding user avatar in stream

This probably the most frequently asked question, so i will go more in detail on this. First of all, it's good to know that you can approach this as a themer, as a developer only only wanting to implement this (ready to go).

Through theming

  1. heartbeat_message_row.tpl.php can be overriden where you can use the $message activity variable $message->actor to theme your image (imagecache or by invoking user_picture)

Ready to go

  1. Using rules, in new releases the avatar is available from heartbeat to show the avatar of the actor. This is only available in versions later than 19/08/2010, the date of the creation of this post.
  2. With Display Suite: You arrange your fields through the display suite UI. You will be able to choose formatters for it there as well.

Through custom development

  1. In the message template, you can use !avatar.
    - By invoking the api log function, we can easily implement the value for the avatar. The variables section just will hold the "@avatar" replacement pattern, like
    (theme('imagecache', 'tiny_picture', $message->actor->picture), 'user/' . $message->actor->uid, array('html' => TRUE)), ?>
    - By using rules heartbeat logging. In this case, the variable will be assigned to a token. The avatar token for the message actor avatar is added on 19/08/2010 in DRUPAL-6--4-9 and will certainly included in the DRUPAL-6--4-10.
    To add such a token, you will need to add a token in code, being two lines, one for the list and one for the value. Underneath in that order:
    $tokens['heartbeat_message']['heartbeat-actor-picture'] = t("Avatar of the actor with a link to it leading to the user account page.");
    $values['heartbeat-actor-picture'] = l(theme('user_picture', $object->actor), 'user/' . $object->actor->uid, array('html' => TRUE));
  2. Implementing hook_heartbeat_theme_alter  where you can loop through eacy message and do something like: $myavatar . $message->message where myavatar is again the code to produce your avatar (mostly by invoking the theme imagecache function to load your preset.