You are here

function cloud_zoom_field_formatter_view in Cloud Zoom 8

Same name and namespace in other branches
  1. 7 cloud_zoom.module \cloud_zoom_field_formatter_view()

Implements hook_field_formatter_view().

File

./cloud_zoom.module, line 442
This module integrates the Cloud Zoom JQuery library from: http://www.professorcloud.com/mainsite/cloud-zoom.htm

Code

function cloud_zoom_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  $settings = $display['settings'];
  $cloud_zoom_settings = cloud_zoom_settings_info();
  $variables = array();
  foreach ($cloud_zoom_settings as $key => $info) {
    $variables['#' . $key] = !empty($info['fieldset']) ? $settings[$info['fieldset']][$key] : $settings[$key];
  }
  if (!$settings['gallery_fieldset']['gallery_mode']) {

    // Build elements for each item.
    foreach ($items as $delta => $item) {
      $element[$delta] = array(
        '#theme' => 'cloud_zoom_image',
        '#item' => $item,
      );
      $element[$delta] += $variables;
    }
  }
  else {
    $element = array(
      '#theme' => 'cloud_zoom_image_gallery',
      '#items' => $items,
    );
    $element += $variables;
  }
  return $element;
}