function imagecache_profiles_preprocess_user_picture in ImageCache Profiles 6
Same name and namespace in other branches
- 7 imagecache_profiles.module \imagecache_profiles_preprocess_user_picture()
Overrides process variables for user-picture.tpl.php
Originally variables are built by template_preprocess_user_picture() locate in core user.module.
The $variables array contains the following arguments:
- $account
See also
File
- ./
imagecache_profiles.module, line 24
Code
function imagecache_profiles_preprocess_user_picture(&$variables) {
$default = $variables['picture'];
if (variable_get('user_pictures', 0)) {
$account = $variables['account'];
if (isset($account->imagecache_preset)) {
// Manually set preset (e.g. Views)
$preset = $account->imagecache_preset;
}
elseif (variable_get('user_picture_imagecache_profiles_default', '')) {
// Default user picture preset.
$preset = variable_get('user_picture_imagecache_profiles_default', '');
}
if (!empty($account->picture) && file_exists($account->picture)) {
$picture = $account->picture;
}
elseif (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')),
));
if (isset($preset)) {
$preset = is_numeric($preset) ? imagecache_preset($preset) : imagecache_preset_by_name($preset);
}
if (empty($preset)) {
$variables['picture'] = $default;
//theme('image', $picture, $alt, $alt, '', FALSE);
}
else {
if (!empty($account->uid) && user_access('access user profiles')) {
$attributes = array(
'attributes' => array(
'title' => t('View user profile.'),
),
'html' => TRUE,
);
$image = theme('imagecache', $preset['presetname'], $picture, $alt, $alt);
$variables['picture'] = l($image, "user/{$account->uid}", $attributes);
}
else {
$variables['picture'] = theme('imagecache', $preset['presetname'], $picture, $alt, $alt);
}
}
}
}
}