You are here

function template_preprocess_field_slideshow_pager in Field Slideshow 7

Same name and namespace in other branches
  1. 8 field_slideshow.module \template_preprocess_field_slideshow_pager()
  2. 8.2 field_slideshow.module \template_preprocess_field_slideshow_pager()
  3. 7.2 field_slideshow.module \template_preprocess_field_slideshow_pager()

Implements template_preprocess().

File

./field_slideshow.module, line 1034
Implement a slideshow formatter for fields.

Code

function template_preprocess_field_slideshow_pager(&$variables) {

  // Add thumbnails pager/carousel if needed
  if (isset($variables['pager']) && ($variables['pager'] == 'image' || $variables['pager'] == 'carousel')) {
    if ($variables['pager'] == 'carousel') {
      $thumbnail_style = $variables['carousel_image_style'];
      $path = libraries_get_path('jquery.jcarousel');
      if (isset($variables['carousel_skin']) && $variables['carousel_skin']) {
        drupal_add_css($path . '/skins/' . $variables['carousel_skin'] . '/skin.css');
      }
    }
    else {
      $thumbnail_style = $variables['pager_image_style'];
    }
    $thumbnails = array();
    foreach ($variables['items'] as $num => $item) {
      $thumbnail = array();
      $thumbnail['path'] = $item['uri'];
      $thumbnail['attributes']['class'] = array(
        'field-slideshow-thumbnail',
        'field-slideshow-thumbnail-' . (1 + $num),
      );
      $thumbnail['alt'] = isset($item['alt']) ? $item['alt'] : '';
      if (isset($item['width']) && isset($item['height'])) {
        $thumbnail['width'] = $item['width'];
        $thumbnail['height'] = $item['height'];
      }
      else {
        $thumbnail_dims = getimagesize($thumbnail['path']);
        $thumbnail['width'] = $thumbnail_dims[0];
        $thumbnail['height'] = $thumbnail_dims[1];
      }
      if (isset($item['title']) && drupal_strlen($item['title']) > 0) {
        $thumbnail['title'] = $item['title'];
      }
      if ($thumbnail_style) {
        $thumbnail['style_name'] = $thumbnail_style;
        $thumbnail_output = theme('image_style', $thumbnail);
      }
      else {
        $thumbnail_output = theme('image', $thumbnail);
      }
      $thumbnails[] = '<a href="#">' . $thumbnail_output . '</a>';
    }
    $variables['thumbnails'] = theme('item_list', array(
      'items' => $thumbnails,
      'attributes' => array(
        'id' => 'field-slideshow-' . $variables['slideshow_id'] . '-pager',
        'class' => 'field-slideshow-pager slides-' . count($variables['items']),
      ),
    ));
  }
}