function ds_render_user_picture in Display Suite 7.2
Same name and namespace in other branches
- 7 ds.module \ds_render_user_picture()
Render a user picture.
1 string reference to 'ds_render_user_picture'
- ds_ds_fields_info in ./
ds.ds_fields_info.inc - Implements hook_ds_fields_info().
File
- ./
ds.module, line 1118 - Display Suite core functions.
Code
function ds_render_user_picture($field) {
$picture = ds_return_picture($field['entity']);
if (!empty($picture)) {
$filepath = isset($picture->uri) ? $picture->uri : $picture;
$name = format_username($field['entity']);
$alt = t("@user's picture", array(
'@user' => $name,
));
$vars = array(
'path' => $filepath,
'alt' => $alt,
'title' => $alt,
);
// If the image does not have a valid Drupal scheme (for eg. HTTP),
// don't load image styles.
if (module_exists('image') && file_valid_uri($filepath)) {
$vars['style_name'] = str_replace('ds_picture_', '', $field['formatter']);
$image = theme('image_style', $vars);
}
else {
$image = theme('image', $vars);
}
if (!empty($field['entity']->uid) && user_access('access user profiles')) {
return l($image, 'user/' . $field['entity']->uid, array(
'html' => TRUE,
));
}
else {
return $image;
}
}
}