function template_preprocess_user_picture
7.x user.module | template_preprocess_user_picture(&$variables) |
6.x user.module | template_preprocess_user_picture(&$variables) |
Process variables for user-picture.tpl.php.
The $variables array contains the following arguments:
- $account
See also
File
- drupal-6.x/
modules/ user/ user.module, line 837 - 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);
}
}
}
}