Same name and namespace in other branches
  1. 7.x modules/user/user.module \template_preprocess_user_picture()

Process variables for user-picture.tpl.php.

The $variables array contains the following arguments:

  • $account

See also

user-picture.tpl.php

File

modules/user/user.module, line 844
Enables the user registration and login system.

Code

function template_preprocess_user_picture(&$variables) {
  $variables['picture'] = '';
  if (variable_get('user_pictures', 0)) {
    $account = $variables['account'];
    if (!empty($account->picture) && file_exists($account->picture)) {
      $picture = file_create_url($account->picture);
    }
    else {
      if (variable_get('user_picture_default', '')) {
        $picture = variable_get('user_picture_default', '');
      }
    }
    if (isset($picture)) {
      $alt = t("@user's picture", array(
        '@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous')),
      ));
      $variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
      if (!empty($account->uid) && user_access('access user profiles')) {
        $attributes = array(
          'attributes' => array(
            'title' => t('View user profile.'),
          ),
          'html' => TRUE,
        );
        $variables['picture'] = l($variables['picture'], "user/{$account->uid}", $attributes);
      }
    }
  }
}