It's easy to build a view that extracts all the images associated with a node.

It's easy to build a view that extracts the first image associated with a node.

It's easy to build a view that extracts the 10th image associated with a node (or any other constant value).

But is it possible to build a view that extracts the Nth image associated with a node, where N is an argument to the views call? If so, how is it done?

Much obliged for any help that can be provided.

Comments

merlinofchaos’s picture

Project: Views (for Drupal 7) » Content Construction Kit (CCK)
Version: 6.x-2.7 » 6.x-2.x-dev
Component: Miscellaneous » Views Integration

Not sure. Checking with CCK folks -- I can't remember if there's a way to control which field(s) are extracted by delta or not.

markus_petrux’s picture

Status: Active » Fixed

Try with latest dev snapshot. Multiple value fields expose the delta key to Views as field, filter, argument, ...

MadOverlord’s picture

Thanks very much for the help. I managed to puzzle out how to do it once given the important clue.

Some notes for the next person trying to do this after adding a delta argument.

1) You must ensure that the Content: Image field has Group Multiple Values unchecked, otherwise you will get all the Images, not just the one you want.

2) If you set the Content: Image delta argument to allow multiple values, you can use arguments like 1+2+3, but you need to make sure that Items to Display is set to unlimited. Also, 1+2+3 and 3+2+1 both appear to display in order 1+2+3.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

drahman’s picture

You say "It's easy to build a view that extracts the first image associated with a node."

I have built a block view showing thumbnails of Ubercart products. I only want the first image (thumbnail) associated with the product node to show in the view. I am hoping that this is something I can do in the view settings. Maybe in Filters?

I am not sure if you can shed any light on this or if it is an Ubercart issue. I have searched all through the Ubercart forums with no luck. I am grasping at straws now.

Any help you can give would be greatly appreciated.

Thank you very much in advance!

MadOverlord’s picture

IIRC, something like a content: image field, with group multiple values checked, but items to display set to 1, will get you what you want. Or see my reply #3, and set the delta argument to 1