You are here

function imagezoom_gallery_field_formatter_view in Image Zoom 7.2

Implements hook_field_formatter_view().

File

modules/imagezoom_gallery/imagezoom_gallery.module, line 72
Provides a gallery formatter for the Image Zoom module.

Code

function imagezoom_gallery_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

  // If there are no items, don't do anything.
  if (empty($items)) {
    return array();
  }
  $display_style = $display['settings']['imagezoom_display_style'];
  $zoom_style = $display['settings']['imagezoom_zoom_style'];
  $thumb_style = $display['settings']['imagezoom_thumb_style'];
  $settings = array(
    'zoomType' => $display['settings']['imagezoom_zoom_type'],
    'gallery' => 'imagezoom-thumb-wrapper',
  );
  if ($display['settings']['imagezoom_disable']) {
    $settings['responsive'] = TRUE;
    $settings['respond'] = array(
      array(
        'range' => '0 - ' . $display['settings']['imagezoom_disable_width'],
        'enabled' => FALSE,
      ),
    );
  }
  $additonal_settings = imagezoom_settings_to_array($display['settings']['imagezoom_additional']);
  $settings += $additonal_settings;
  $context = array(
    'field' => $field,
    'instance' => $instance,
  );
  drupal_alter('imagezoom_settings', $settings, $context);
  $element = array(
    '#theme' => 'imagezoom_gallery',
    '#items' => $items,
    '#display_style' => $display_style,
    '#zoom_style' => $zoom_style,
    '#thumb_style' => $thumb_style,
    '#settings' => $settings,
  );
  return $element;
}