function drupagram_views_handler_field_images::render in Drupagram 7
Same name and namespace in other branches
- 6 views/drupagram_views_handler_field_images.inc \drupagram_views_handler_field_images::render()
Render the field.
Parameters
array $values: The values retrieved from the database.
Overrides views_handler_field::render
File
- ./
drupagram_views_field_handlers.inc, line 289 - Drupagram views field handlers.
Class
- drupagram_views_handler_field_images
- Field handler to provide simple renderer that turns a URL into a clickable link.
Code
function render($values) {
$value = $values->{$this->field_alias};
$images = unserialize($value);
if (!empty($this->options['source'])) {
$source = $this->options['source'];
}
$caption_text = '';
if ($this->options['use_caption_for_alt_text'] && isset($values->drupagram_caption) && !empty($values->drupagram_caption)) {
$caption = unserialize($values->drupagram_caption);
$caption_text = check_plain($caption['text']);
}
if ($this->options['source'] == 'local') {
if ($remote = $this
->get_value($values)) {
$images = unserialize($remote);
$picture = drupagram_local_image($images['standard_resolution']['url']);
$picture_filepath = $picture->uri;
if (file_valid_uri($picture_filepath)) {
if (module_exists('image') && !empty($this->options['image_style'])) {
$image = theme('image_style', array(
'style_name' => $this->options['image_style'],
'path' => $picture_filepath,
'alt' => $caption_text,
));
}
else {
$image = theme('image', array(
'path' => $picture_filepath,
'alt' => $caption_text,
));
}
}
}
}
else {
$path = $images[$source]['url'];
if ($this->options['secure']) {
$path = str_replace('http://', 'https://', $path);
}
$image = theme('image', array(
'path' => $path,
'alt' => $caption_text,
));
}
if ($this->options['link_to_post'] && isset($values->drupagram_link) && !empty($values->drupagram_link)) {
return l($image, $values->drupagram_link, array(
'html' => TRUE,
'attributes' => array(
'target' => '_blank',
'rel' => 'nofollow',
),
));
}
return $image;
}