function shadowbox_field_formatter in Shadowbox 5
Same name and namespace in other branches
- 5.2 shadowbox.module \shadowbox_field_formatter()
Implementation of hook_field_formatter().
File
- ./
shadowbox.module, line 571 - Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.
Code
function shadowbox_field_formatter($field, $item, $formatter) {
if (module_exists('imagefield') && module_exists('imagecache')) {
if (isset($item['filepath'])) {
$filepath =& $item['filepath'];
}
else {
if (!empty($item['fid'])) {
$file = _imagefield_file_load($item['fid']);
$filepath =& $file['filepath'];
}
else {
return '';
}
}
$item = array_merge($item, (array) $file);
$item['filepath'] = $filepath;
if (strpos($formatter, 'shadowbox][') !== FALSE || strpos($formatter, 'shadowbox_gallery][') !== FALSE) {
list($null, $view_preset, $shadowbox_preset) = explode('][', $formatter, 3);
$item['shadowbox_preset'] = $shadowbox_preset;
$rules = array();
if (function_exists('imagecache_presets')) {
$presets = imagecache_presets();
foreach ($presets as $preset_id => $preset_info) {
$rules[$preset_id] = $preset_info['presetname'];
}
}
else {
$rules = _imagecache_get_presets();
}
if ($view_preset == 'original' || in_array($view_preset, (array) $rules)) {
$gallery = strpos($formatter, 'shadowbox_gallery][') !== FALSE ? TRUE : FALSE;
return theme('imagefield_image_imagecache_shadowbox', $view_preset, $field, $item, NULL, $gallery);
}
}
}
}