function theme_linkimagefield_imagecache in Link Image Field 6
1 string reference to 'theme_linkimagefield_imagecache'
File
- ./
linkimagefield.module, line 278 - Defines a link image field type.
Code
function theme_linkimagefield_imagecache($element) {
$field = content_fields($element['#field_name']);
$item = $element['#item'];
$formatter = $element['#formatter'];
if (empty($item['fid']) && $field['use_default_image']) {
$item = $field['default_image'];
}
// Views does not load the file for us, while CCK display fields does.
if (empty($item['filepath'])) {
$item = array_merge($item, field_file_load($item['fid']));
}
if (is_string($item['data'])) {
$item['data'] = unserialize($item['data']);
}
$alt = empty($item['data']['alt']) ? '' : $item['data']['alt'];
$title = empty($item['data']['title']) ? '' : $item['data']['title'];
$url = empty($item['data']['url']) ? '' : $item['data']['url'];
$parts = explode('_', $formatter);
$style = array_pop($parts);
$presetname = implode('_', $parts);
$class = "linkimagefield imagecache imagecache-{$presetname} imagecache-{$style} imagecache-{$formatter}";
if ($preset = imagecache_preset_by_name($presetname)) {
$item['filepath'] = $item['fid'] == 'upload' ? $item['preview'] : $item['filepath'];
$imagetag = theme('imagecache', $presetname, $item['filepath'], $alt, $title);
return l($imagetag, $url, array(
'attributes' => array(
'class' => $class,
),
'html' => TRUE,
));
}
return '<!-- linkimagefield formatter imagecache preset(' . $presetname . ') not found! -->';
/*if (isset($element['#item']['nid']) && $node = node_load($element['#item']['nid'])) {
$imagecache_html = module_invoke('imagecache', 'field_formatter', $element['#field_name'], $element['#item'], $element['#formatter'], $node);
//return '<a href="'. $element['#item']['data']['url'] .'">'. $imagecache_html .'</a>';
return l($imagecache_html, $element['#item']['data']['url'], array('attributes' => array('class' => $class), 'html' => TRUE));
}*/
}