5 replies [Last post]
half_brick's picture
Offline
Joined: 02/04/2008
Juice: 82
Was this information Helpful?

I have a problem in that I have a bunch of products each with multiple images.
However the images were uploaded automatically and in no particular order.

Now when I view the products in a view etc, the first image from the field_image_cache is shown, but this is not always the best image (it is often the back of the product or similar).

I thought that I could fix this by implementing hook_load or hook_nodeapi and sorting the images (based on alt tags for now). This works when viewing an individual node, but it turns out this is not called consistently when in views or when viewing a cart or similar.

Is there a surefire way of reordering these images?

Surely someone has had this problem before?

Cheers

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: sorting/arranging product images

Unfortunately, there isn't an easy "Drupalish" way to reorder CCK images. Instead, you're going to have to hack the database. The order the images are in is determined by the values in the "delta" column of the content_field_image_cache table. For each vid, rearrange the delta values so that 0 is the first image you want, and the rest in ascending order. Refer to the files table to see what values the fid key point to.

half_brick's picture
Offline
Joined: 02/04/2008
Juice: 82
Re: Re: sorting/arranging product images

Yea, I've been that deep, and tried altering the delta...
To no effect though.
Perhaps caching was just obscuring what I was trying to do.

I'll try that again at some point.
Cheers for your help.

(I hope they're putting this functionality in a future version of CCK BTW. It's a pretty big issue)

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: sorting/arranging product images

Ah yes. Forgot about the cache table. You can empty any and all of the cache tables and Drupal will just rebuild them.

half_brick's picture
Offline
Joined: 02/04/2008
Juice: 82
Re: sorting/arranging product images

Just to clarify, we'd be talking about the view cache tables here?
I coulda sworn I truncated all cache tables recently, and my site didn't exactly recover gracefully...

If modifying the delta works; I may try to write a "for the time being" module that provides a JS drag and drop interface for rearranging images on the edit page.

Cheers

cmcgarry's picture
Offline
Joined: 04/15/2009
Juice: 15
Ever been resolved

Half_Brick...did you ever find a solution for this short of modifying the database? Any help on this issue would be appreciated.

Thanks!