1 views_handler_field_user_picture.inc | views_handler_field_user_picture::render($values) |
Render the field.
Parameters
$values: The values retrieved from the database.
Overrides views_handler_field::render
File
- core/
modules/ user/ views/ views_handler_field_user_picture.inc, line 75 - Definition of views_handler_field_user_picture.
Class
- views_handler_field_user_picture
- Field handler to provide simple renderer that allows using a themed user link.
Code
function render($values) {
if ($this->options['image_style'] && module_exists('image')) {
// @todo: Switch to always using theme('user_picture') when it starts
// supporting image styles. See http://drupal.org/node/1021564
if ($picture_fid = $this->get_value($values)) {
$picture = file_load($picture_fid);
$picture_filepath = $picture->uri;
}
else {
$picture_filepath = config_get('system.core', 'user_picture_default');
}
if (file_valid_uri($picture_filepath)) {
$output = theme('image_style', array('style_name' => $this->options['image_style'], 'uri' => $picture_filepath));
if ($this->options['link_photo_to_profile'] && user_access('access user profiles')) {
$uid = $this->get_value($values, 'uid');
$output = l($output, "user/$uid", array('html' => TRUE));
}
}
else {
$output = '';
}
}
else {
// Fake an account object.
$account = new stdClass();
if ($this->options['link_photo_to_profile']) {
// Prevent template_preprocess_user_picture from adding a link
// by not setting the uid.
$account->uid = $this->get_value($values, 'uid');
}
$account->name = $this->get_value($values, 'name');
$account->mail = $this->get_value($values, 'mail');
$account->picture = $this->get_value($values);
$output = theme('user_picture', array('account' => $account));
}
return $output;
}