function gravatar_preprocess_user_picture in Gravatar integration 6
Same name and namespace in other branches
- 7 gravatar.module \gravatar_preprocess_user_picture()
Override template_preprocess_user_picture() to display user pictures with Gravatar integration.
See also
template_preprocess_user_picture()
_gravatar_get_account_user_picture()
1 call to gravatar_preprocess_user_picture()
File
- ./
gravatar.module, line 127 - Integrates gravatar service for user pictures.
Code
function gravatar_preprocess_user_picture(&$variables) {
$variables['picture'] = '';
if (variable_get('user_pictures', 0)) {
// Load the full user object since it is not provided with nodes, comments,
// or views displays.
$account = _gravatar_load_account($variables['account']);
$picture = _gravatar_get_account_user_picture($account);
if (!empty($picture)) {
$alt = t("@user's picture", array(
'@user' => $account->name,
));
$variables['picture'] = theme('image', $picture, $alt, $alt, NULL, FALSE);
if ($account->uid && user_access('access user profiles')) {
// Create link to the user's profile.
$attributes = array(
'title' => t('View user profile.'),
);
$variables['picture'] = l($variables['picture'], 'user/' . $account->uid, array(
'attributes' => $attributes,
'html' => TRUE,
));
}
elseif (!empty($account->homepage)) {
// If user is anonymous, create link to the commenter's homepage.
$attributes = array(
'title' => t('View user website.'),
'rel' => 'external nofollow',
);
$variables['picture'] = l($variables['picture'], $account->homepage, array(
'attributes' => $attributes,
'html' => TRUE,
));
}
}
}
}