You are here

function lightbox2_imagefield_image_imagecache in Lightbox2 6

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

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

Parameters

$field_name: The field name 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.

Return value

The themed imagefield + imagecache image and link.

1 call to lightbox2_imagefield_image_imagecache()
theme_lightbox2_formatter_imagefield in ./lightbox2.formatter.inc
Handler for Lightbox2 display of imagecache + imagefield CCK fields.

File

./lightbox2.formatter.inc, line 76
Lightbox2 formatter hooks and callbacks.

Code

function lightbox2_imagefield_image_imagecache($field_name, $item, $formatter, $node, $view_preset, $lightbox_preset, $args = array()) {

  // Load file data if missing
  if (!isset($item['filepath']) && !empty($item['fid'])) {
    $file = field_file_load($item['fid']);
    $item = array_merge($item, (array) $file);
  }
  elseif (!isset($item['filepath'])) {

    // No file in field, return.
    return '';
  }
  $args['lightbox_preset'] = $lightbox_preset;

  // Check view_preset for existence.
  $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 == 'link' || $view_preset == 'original' || in_array($view_preset, (array) $rules)) {
    $rel = 'lightbox';
    if (strpos($formatter, '__lightshow2__') !== FALSE) {
      $rel = 'lightshow';
    }
    elseif (strpos($formatter, '__lightshow2_compact__') !== FALSE) {
      $rel = 'lightshow';
      $args['compact'] = TRUE;
    }
    elseif (strpos($formatter, '__lightframe2__') !== FALSE) {
      $rel = 'lightframe';
    }

    // Check if this is a compact display.
    list($tmp, $lightbox_type, $tmp) = explode('__', $formatter, 3);
    if ($lightbox_type == 'lightbox2_compact') {
      $args['compact'] = TRUE;
    }
    return theme('imagefield_image_imagecache_lightbox2', $view_preset, $field_name, $item, $node, $rel, $args);
  }
}