function thickbox_field_formatter in Thickbox 5
Same name and namespace in other branches
- 6 thickbox.module \thickbox_field_formatter()
Implementation of hook_field_formatter().
File
- ./
thickbox.module, line 197 - Author: Fredrik Jonsson fredrik at combonet dot se The thickbox module is a simple wrapper for the jquery plugin ThickBox http://jquery.com/demo/thickbox/.
Code
function thickbox_field_formatter($field, $item, $formatter, $node = NULL) {
if (module_exists('imagefield') && module_exists('imagecache') && !empty($item['fid'])) {
if (!isset($item['filepath'])) {
$file = _imagefield_file_load($item['fid']);
$item['filepath'] = $file['filepath'];
}
if (strpos($formatter, 'thickbox][') !== FALSE) {
list($null, $namespace) = explode('][', $formatter, 2);
$nid = $item['nid'] ? $item['nid'] : ($node->nid ? $node->nid : '');
switch (variable_get('thickbox_imagefield_gallery', 1)) {
case 0:
$gallery_id = 'all';
break;
case 1:
$gallery_id = $nid;
break;
case 2:
$gallery_id = $nid . '-' . $field['field_name'];
break;
case 3:
$gallery_id = $nid . '-' . $item['fid'];
break;
}
if ($preset = imagecache_preset_by_name($namespace)) {
return theme('imagefield_image_imagecache_thickbox', $namespace, $field, $item['filepath'], $item['alt'], $item['title'], $gallery_id);
}
}
}
}