You are here

function lightbox2_field_formatter in Lightbox2 5

Same name and namespace in other branches
  1. 5.2 lightbox2.module \lightbox2_field_formatter()

Implementation of hook_field_formatter().

File

./lightbox2.module, line 291

Code

function lightbox2_field_formatter($field, $item, $formatter) {
  if (module_exists('imagefield') && module_exists('imagecache')) {
    if (!isset($item['fid'])) {
      return '';
    }
    if (!$_LIGHTBOX2_INCLUDE && lightbox2_exclude_these_paths() != 1) {
      lightbox2_add_files();
      $_LIGHTBOX2_INCLUDE = true;
    }
    $file = _imagefield_file_load($item['fid']);
    $item = array_merge($item, $file);
    if (strpos($formatter, 'lightbox2][') !== false) {
      list($null, $namespace) = explode('][', $formatter, 2);
      $rules = _imagecache_get_presets();
      if (in_array($namespace, (array) $rules)) {
        return theme('imagefield_image_imagecache_lightbox2', $namespace, $field, $item);
      }
    }
  }
}