I have a content type with an imagefield, that can have unlimited number of values (images).
I defined a view displaying the nodes, showing this imagefield too via Lightbox2. As the node can have several images attached, they're all displayed in the row of the node. I'd like to show only the first image, hiding the others. If I configure the image field in the view to show only one value, Lightbox2 can't detect that there are other images attached to the node, so there is no next button when Lightbox2 invoked.

How could I hide the other images in the row, but letting Lightbox2 have them?

See attachment.

CommentFileSizeAuthor
#2 lightbox2.png16.12 KBtian
lightbox2.png17.96 KBtian
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tian’s picture

Using Stella's idea I managed to create the theme code for what I wanted:

In my theme's template.php I put

function mytheme_content_view_multiple_field($items, $field, $values) {
  $output = '';
  $i = 0;
  foreach ($items as $item) {
    if (!empty($item) || $item == '0') {
      if ($i) {
        $output .= '<div class="field-item-hidden">'. $item .'</div>';
      } else {
        $output .= '<div class="field-item">'. $item .'</div>';
        $i++;
      }
    }
  }
  return $output;
}

and in style.css I put

div.field-item-hidden {
   display: none;
}

which hides the items except the first one.

tian’s picture

FileSize
16.12 KB

Forgot to attach the result, here it is: