Community Documentation

Author Pane user picture (avatar)

Last updated May 2, 2011. Created by Michelle on September 20, 2009.
Edited by HongPong. Log in to edit this page.

The Author Pane module deliberately does not use the theme_user_picture() function for displaying the user picture (avatar) to allow greater control over it in specific pane instances. Instead, it uses the function author_pane_user_picture($account, $caller, $picture_preset) which is called from template_preprocess_author_pane() to get the user picture formatted to display on that pane instance.

Parameters:

  • $account - The fully loaded user object. If all you have is a UID, you can get the object with $account = user_load($uid); where $uid is a variable holding the user id.
  • $caller - (optional) This ID comes from the preprocess_author_pane and is passed through as a way to track who is calling the function. By checking the $caller, you could, for example, link the avatar on forum posts but not on the user profile page. (This is an example and is not actually implemented.)
  • $picture_preset - (optional) This is an imagecache picture preset that, if given, and if imagecache is enabled, will be used to size the user picture on the author pane instance.

You generally will not need to call this function on your own as it is already called from within template_preprocess_author_pane() . Because this is a template based theme function, however, you can hook into it via the preprocess system. This way you can make changes either globally or based on $caller without having to hack the module code.

The template file it uses is author-pane-user-picture.tpl.php. As of this writing, neither Advanced Forum nor Advanced Profile Kit have their own versions of this file. You could use different template files in different places by checking the caller and setting the template suggestion accordingly.

The default presentation of the picture depends on whether you are using Imagecache. If an Imagecache preset is passed in (set in Advanced Forum, the content pane (APK or stand-alone), the block, or passed in the theme function), the picture will be presented as the imagecached version linked to the full sized version. If you have Lightbox2 installed, it will open the full sized version in a lightbox. Otherwise it will show on a new page. If you are not using an imagecache preset, it will use the full sized picture unlinked.

The template file can be modified by copying it to your theme. One often requested feature is to link to the user page as is done when theme_user_picture is used. To do that, you would change the template to print the picture like this:

<a href="/user/<?php print $account->uid; ?>"><?php print $picture; ?></a>

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Developers and coders, Site administrators, Themers

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here