You are here

function theme_cloud_zoom_image_gallery in Cloud Zoom 8

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

Theme handler for the cloud_zoom effect with gallery

1 theme call to theme_cloud_zoom_image_gallery()
cloud_zoom_field_formatter_view in ./cloud_zoom.module
Implements hook_field_formatter_view().

File

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

Code

function theme_cloud_zoom_image_gallery($variables) {

  // Add the Cloud Zoom Library
  drupal_add_library('cloud_zoom', 'cloud-zoom');
  $items = $variables['items'];

  // Create the gallery thumb syntax of cloud zoom.
  $gallery_item = '<div class="cloud-zoom-gallery-thumbs">';
  $options_rel = cloud_zoom_get_rel_string($variables);
  $main_item = '';
  $id = drupal_html_id('cloud-zoom');
  $classes = array(
    'cloud-zoom',
  );

  // Use colorbox?
  if (!empty($variables['colorbox']) && module_exists('colorbox')) {
    $classes[] = 'colorbox';
  }
  foreach ($items as $delta => $item) {

    // Build images.
    $zoomed = $variables['zoom_style'] ? image_style_url($variables['zoom_style'], $item['uri']) : file_create_url($item['uri']);
    $slide = cloud_zoom_get_img_tag($variables['slide_style'], $item);
    $thumb = cloud_zoom_get_img_tag($variables['thumb_style'], $item);
    $slide_url = $variables['slide_style'] ? image_style_url($variables['slide_style'], $item['uri']) : $item['uri'];
    if ($delta == 0) {

      // This is the large image.
      $options = array(
        'html' => TRUE,
        'attributes' => array(
          'class' => $classes,
          'id' => $id,
          'rel' => $options_rel,
        ),
      );
      $main_item = l($slide, $zoomed, $options);
    }

    // These are the thumbnail.
    $options = array(
      'html' => TRUE,
      'attributes' => array(
        'class' => 'cloud-zoom-gallery',
        'rel' => 'useZoom: \'' . $id . '\',smallImage: \'' . $slide_url . '\'',
      ),
    );
    $gallery_item .= l($thumb, $zoomed, $options);
  }
  $gallery_item .= '</div>';

  // Return the preview image as a link to the larger image with a cloud-zoom
  // CSS class.
  return '<div class="cloud-zoom-container">' . $main_item . $gallery_item . '</div>';
}