You are here

function lightbox2_imagefield_image_imagecache in Lightbox2 5.2

Same name and namespace in other branches
  1. 6 lightbox2.formatter.inc \lightbox2_imagefield_image_imagecache()

Function to set up the data needed for theme_imagefield_image_imagecache_lightbox2().

Parameters

$field: The field the action is being performed on.

$item: An array, keyed by column, of the data stored for this item in this field.

$formatter: The formatter to use for the field.

$node: The node object.

$view_preset: The imagecache preset to be displayed on the node or in the view.

$lightbox_preset: The imagecache preset to be displayed in the lightbox.

1 call to lightbox2_imagefield_image_imagecache()
lightbox2_field_formatter in ./lightbox2.module
Implementation of hook_field_formatter().

File

./lightbox2.module, line 1822
Enables the use of lightbox2 which places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths.

Code

function lightbox2_imagefield_image_imagecache($field, $item, $formatter, $node, $view_preset, $lightbox_preset) {
  if (isset($item['filepath'])) {
    $filepath =& $item['filepath'];
  }
  elseif (!empty($item['fid'])) {
    $file = _imagefield_file_load($item['fid']);
    $filepath =& $file['filepath'];
  }
  else {
    return '';
  }
  $item = array_merge($item, (array) $file);
  $item['filepath'] = $filepath;
  $item['lightbox_preset'] = $lightbox_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)) {
    $rel = 'lightbox';
    if (strpos($formatter, 'lightshow2][') !== FALSE) {
      $rel = 'lightshow';
    }
    elseif (strpos($formatter, 'lightframe2][') !== FALSE) {
      $rel = 'lightframe';
    }
    return theme('imagefield_image_imagecache_lightbox2', $view_preset, $field, $item, $node, $rel);
  }
}