You are here

function theme_gallery_teaser in Node Gallery 6

1 theme call to theme_gallery_teaser()
node_gallery_preprocess_node in ./node_gallery.module

File

./node_gallery.themes.inc, line 52
Node gallery themes.

Code

function theme_gallery_teaser($gallery, $config) {

  //cover display
  if ($config->teaser['gallery_display_type'] == 'cover') {

    // Make sure to avoid an "Invalid argument supplied for foreach()" error
    if ($gallery->images) {
      $no_cover = TRUE;
      foreach ($gallery->images as $image) {
        if ($image->is_cover) {
          $cover = $image;
          $no_cover = FALSE;
          break;
        }
      }
      unset($image);

      // If there is no cover image, use the first one
      if ($no_cover == TRUE) {
        $cover = $gallery->images[0];
      }
    }
    $cover->filepath = empty($cover->filepath) ? $config->default_cover : $cover->filepath;
    $cover->title = $gallery->title;
    $image_tag = theme('image_view', $config->image_size['cover'], $cover);
    return l($image_tag, 'node/' . $gallery->nid, array(
      'html' => TRUE,
    ));
  }
  elseif ($config->teaser['gallery_display_type'] == 'lightbox2_gallery' && module_exists('lightbox2')) {

    // Note - There is no display num, as lightbox2 will require seeing all
    // thumbs
    // Make sure to avoid an "Invalid argument supplied for foreach()" error
    if ($gallery->images) {
      foreach ($gallery->images as $image) {
        $image_tag = theme('image_view', $config->image_size['thumbnail'], $image);
        $items[] = l($image_tag, imagecache_create_url($config->teaser['lightbox2_gallery'], $image->filepath), array(
          'html' => TRUE,
          'attributes' => array(
            'rel' => 'lightshow[' . $gallery->nid . ']',
          ),
        ));
      }
    }
    return theme('item_list', $items);
  }
  else {

    // return thumbnail display
    $display_num = $config->teaser['thumbnails_num'];
    $i = 0;

    // Make sure to avoid an "Invalid argument supplied for foreach()" error
    if ($gallery->images) {
      foreach ($gallery->images as $image) {
        if ($i < $display_num) {
          $image_tag = theme('image_view', $config->image_size['thumbnail'], $image);
          $items[] = l($image_tag, 'node/' . $gallery->nid, array(
            'html' => TRUE,
          ));
        }
      }
    }
    return theme('item_list', $items);
  }
}