I have set up a node that can have multiple images uploaded and it works great, both with only imagefield or by enabling FUpload module, and it's a great solution and answers what I've been looking for. What I'm wondering is if there is a way to have one of the images that has been uploaded, to show in the teaser rather than all of the images.
Right now, in the Display Fields section of the content type, I either have to have images from the imagefield not display in the teaser or if I choose to have the thumbnail link to node all of the images that were uploaded to that node show up. I was hoping to find a way to create a new gallery of images on this node and the new gallery teaser would show up on the front page with one of the images that has been uploaded. Maybe the first in the series of files or some way to select which image would be the "highlight" image of the node and it would show up in the teaser.
Anyone know of a way to do this?
Note: I have used Views to create a listing of the gallery nodes and made it to show only one image from each gallery node, but I was wondering about using the already built in ability that Drupal has to display an imagefield item on the teaser.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dman’s picture

Great feature request.
I think you are right, and there is currently no quick way to select "just one" image from that set in the UI. (I may have missed something)

Me, I usually create an imagefield (limit one) for the representative image and another (unlimited) field for the additional ones. But that's just a work-around. A display widget that render just the 'first' field would be useful... even outside of galleries.
If I wanted what you want, I'd drop back to theme code, but it should be a content management option.

quicksketch’s picture

This has been marked duplicate and won't fix a number of times:

#156528: Show only a subset of multiple images in the teaser
#155577: Show first only the first image
#166603: First image at top of content, remaining images at bottom.
#386046: How do use php to call the first image uploaded from multiple images?

One of the clear problems is that ImageField only provides a few of the "normal" formatters usually used. ImageCache usually adds the formatters for all the thumbnail sizes, ImageField only provides the full-size image formatters.

I think the biggest argument against this is the massive explosion of formatters required. Adding this feature would add 3 formatters to ImageField and 3 formatters for every ImageCache preset.

ImageField would then provide:

Image
Image linked to node
Image linked to file
First image
First image linked to node
First image linked to file

Basically we're looking at a doubling of formatters by adding this option. Add that to Lightbox (which also doubles the number of formatters) and ImageCache (which adds a multiple for every preset) and we're looking at over a hundred formatters if you have 8 ImageCache presets. Until CCK provides configurable formatters, I'm not sure this is a valid option.

daniel-san’s picture

Thank you quicksketch for the reply and for the links to the previous discussions. Those links actually helped me realize the solution to the problem.

For anyone trying to come up with a similar solution:

On the Display Fields window for the imagefield field that you're using for the multi upload, set Teaser to "Thunbnail image linked to node"

Then select the Exclude checkbox

In the node.tpl.php file of your theme add the following line (actually it would be better to add the line to a node-CONTENT_TYPE_NAME.tpl.php file that you add to your theme) :

<?php print $field_YOUR_FIELD_NAME[0]['view'] ?>

in the section below so it looks like this:

<?php if ($page == 0): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
  <?php print $field_YOUR_FIELD_NAME[0]['view'] ?>
<?php endif; ?>

You will then get the very first image of the uploaded images to the node to appear in the teaser.

EvanLovely’s picture

What I usually do is let ImageField handle the Full Node display of images and then enable the Image module and Image Attach module and set the Full Node to hidden. So Image Attach handles the one teaser image.

daniel-san’s picture

EvanL - are you using both Imagefield and Image/Image Attach on the same node? Seems as though you are describing a scenario in which the user is having to double their efforts - upload all the images and then upload one of those images a second time as the image attach file.

I've also been an Image module and Image Gallery user for a long time as well, but I've been investigating using only Imagefield and the surrounding modules given the discussions of moving away from Image module in Drupal. Don't know if that's a definite of course, but maybe someone like quicksketch could help us understand that?

One of the ways you could do what you've described is to create two imagefield fields on a node and designate one of them as the "highlight" image that you would upload the single picture that you want to show in the teaser and the other imagefield field could be the multi upload field that is used for all of the images of the gallery. But, then the user is still doing double duty on the uploading of the images.

The scenario I've described above (#3) is my beginning attempt at a user adding as many images as they would like in a gallery and one of those images being the "highlight" image in the teaser without them having to do anything more than dragging the image that should be the "highlight" image to the top to the list in the node. Amazingly easy since drag and drop is now available to use with imagefield when using the multi-upload feature.

I'm hoping to get a bit of time this week to write up a "how-to" on the whole creation process of this Image Gallery using Imagefield.

quicksketch’s picture

Status: Active » Closed (won't fix)

I'm marking this issue won't fix to go with the previous discussions. Unless someone can propose a valid alternative, this will probably stay this way.

Sunshiney’s picture

Hmmm. Ended up here while looking for a solution to "http://drupal.org/node/582284"

Nevets came up with a nice code idea for node.tpl file only I don't know how to code it. Guess, what I'm asking for is one step above the OP, which makes this not possible without coding. Hmm.. Not sure what to say other than darn. This is a need but I sure do understand Quicksketch's point. What to do...

mandclu’s picture

One way to achieve this would be to have a new field definition called "Imagefield Subset". It could show up as a listed field separately in the CCK interface, so it wouldn't necessary need any formatters of its own (it could re-use existing ones), and therefore wouldn't create the expansion mentioned before. The idea would be, for example, that you could define the full node view to show the full imagefield result and hide the subset, but do the opposite on preview.

For an interface the subset could allow you to choose some images from those loaded into the main imagefield. This could be done by adding checkboxes to the main imagefield listing, or by having a separate interface that could do it in more of a drag and drop style.

In terms of options for the field, maybe you could define a maximum number of images that can be chosen for the subset (defined per content type), as well as whether or not to exclude the subset images from displaying in the main imagefield (in case you wanted to show them both at once).

If I knew more about writing modules for CCK I might be keen to take this on myself, but for now all I can suggest is that based on the list of duplicates above, it certainly seems like it would be a worthwhile endeavour for someone with the needed skills...

dom_b’s picture

i have done this using another imagefield as a teaser, and one for a gallery using galleria. The problem I have is that the teaser doesn't show in the gallery (not a major issue) and i use fupload to do multiple uploads for the gallery which means i have to upload the teaser first otherwise i receive an error.

it would be really great to have a 'use random image as teaser' option!

geerlingguy’s picture

Just an FYI for anyone wishing to do something similar to what was being done in this thread...

In your node-CONTENT_TYPE_HERE.tpl.php file, add something like the following in the content area, and check the 'Exclude' box for your imagefield in the Display Settings for your content type.

  <?php if (!$page): ?>
    <?php /* See also node-view-og_ghp_ron.tpl.php! */ ?>
    <div class="gallery-thumbs">
      <span class="gallery-thumb"><?php print $field_gallery_images[0]['view'] ?></span>
      <span class="gallery-thumb"><?php print $field_gallery_images[1]['view'] ?></span>
      <span class="gallery-thumb"><?php print $field_gallery_images[2]['view'] ?></span>
      <span class="gallery-thumb"><?php print $field_gallery_images[3]['view'] ?></span>
    </div>
  <?php endif; ?>

This code will display the first four field values, for a field named "field_gallery_images." You can add or remove rows as you see fit.

Since I also had these teasers appearing in my Organic Groups nodes, I had to add similar code (replacing the <?php if(!$page): ?> with <?php if($node->type == 'CONTENT_TYPE_HERE'): ?>) to my node-view-og_ghp_ron.tpl.php file.

Scott J’s picture

Could this be done with Custom Formatters module?

geerlingguy’s picture

Yes, it could.

tuxlns’s picture

how could this be done with custom formatters?

tuxlns’s picture

Scott J’s picture

If you're not using views and just want one image to appear in the teaser, try ImageField Single module.

jiakomo’s picture

An alternative solution: If you are using lightbox module, it adds a "compact" formatter.
#513882: Compact view for multiple imagefield

RumpledElf’s picture

You can also use http://drupal.org/project/field_multiple_limit if you're on d7, it adds a checkbox to the fields manage display UI so you can just pick "1" of a multiple field for teasers.

Worked perfectly out of the box with no issues for me.

I'm working on a classifieds site so it was ideal to display the first thumbnail of the item photos in the teaser.

abu-zakham’s picture

Issue summary: View changes
FileSize
5.84 KB

You can set the number of image as screenshot without any module