| 1 |
<?php
|
| 2 |
// $Id: imagefield_formatter.inc,v 1.11 2009/03/20 06:37:36 quicksketch Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* ImageField formatter hooks and callbacks.
|
| 7 |
*/
|
| 8 |
|
| 9 |
function theme_imagefield_formatter_image_plain($element) {
|
| 10 |
// Inside a view $element may contain null data. In that case, just return.
|
| 11 |
if (empty($element['#item']['fid'])) {
|
| 12 |
return '';
|
| 13 |
}
|
| 14 |
|
| 15 |
$field = content_fields($element['#field_name']);
|
| 16 |
$item = $element['#item'];
|
| 17 |
|
| 18 |
$item['data']['alt'] = isset($item['data']['alt']) ? $item['data']['alt'] : '';
|
| 19 |
$item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL;
|
| 20 |
|
| 21 |
$class = 'imagefield imagefield-'. $field['field_name'];
|
| 22 |
return theme('imagefield_image', $item, $item['data']['alt'], $item['data']['title'], array('class' => $class));
|
| 23 |
}
|
| 24 |
|
| 25 |
function theme_imagefield_formatter_image_nodelink($element) {
|
| 26 |
// Inside a view $element may contain null data. In that case, just return.
|
| 27 |
if (empty($element['#item']['fid'])) {
|
| 28 |
return '';
|
| 29 |
}
|
| 30 |
|
| 31 |
$node = $element['#node'];
|
| 32 |
$imagetag = theme('imagefield_formatter_image_plain', $element);
|
| 33 |
$class = 'imagefield imagefield-nodelink imagefield-'. $element['#field_name'];
|
| 34 |
return l($imagetag, 'node/'. $node->nid, array('attributes' => array('class' => $class), 'html' => TRUE));
|
| 35 |
}
|
| 36 |
|
| 37 |
function theme_imagefield_formatter_image_imagelink($element) {
|
| 38 |
// Inside a view $element may contain null data. In that case, just return.
|
| 39 |
if (empty($element['#item']['fid'])) {
|
| 40 |
return '';
|
| 41 |
}
|
| 42 |
|
| 43 |
$item = $element['#item'];
|
| 44 |
$imagetag = theme('imagefield_formatter_image_plain', $element);
|
| 45 |
$original_image_url = file_create_url($item['filepath']);
|
| 46 |
$class = 'imagefield imagefield-imagelink imagefield-'. $element['#field_name'];
|
| 47 |
return l($imagetag, $original_image_url, array('attributes' => array('class' => $class), 'html' => TRUE));
|
| 48 |
}
|