PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Description

This php snippet checks to see if the user has a picture/avatar uploaded and displays it if they have.

Dependencies: No extra modules required but picture support must be enabled to allow users to upload their avatars/pictures:

1) admin/themes/settings/*yourtheme*
Enable 'User pictures in posts' and 'User pictures in comments'

2) admin/settings/user
'Enable' Picture support. You can also set size of avatar.

Usage

  • For use in your user profile page override
  • Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file
  • Tested and works with Drupal 4.5 and 4.6
  • Change the div class names or the prefix text to suit.
<?php  if ($account->picture) { print theme('user_picture', $account); } ?>

NOTES: Thanks to leafish_paul for improving this snippet.

Comments

Anonymous’s picture

In D7 its like

print theme('user_picture', array('account' => $user));

You can also user $node or $comment for account => ''

drupalfan79’s picture

Here is a guideline to enable user picture/avatars: show user picture/avatars