Jump to content

Gallery Image Ordering


garywhitling

Recommended Posts

Not drag-n-drop, but we can make a small edit to the database query that gets all the assigned images for a given product so that the non-main images get sorted by the filename.

In /classes/catalogue .class.php, near the bottom:

Find the private function _productGallery(), then find the statement:

Starts with:

if (($gallery = $GLOBALS['db']->select

Change the end of that line, from:

'ORDER BY i.main_img DESC'))) {

To be:

'ORDER BY i.main_img DESC, filename ASC'))) {

This edit will not survive an upgrade, but there is a hook we can use to resort the $return variable.

Link to comment
Share on other sites

Hi Brian,

Great stuff I have just made the changes you mentioned and that helps for now :-)

Ideally we would like to set the order of the images differently depending on the product page. otherwise we will have to re-name images to get them in-line.

Are you aware of any mods/plugins that offer this?

Regards Gary

Link to comment
Share on other sites

https://www.cubecart.com/extensions/plugins/product-image-rollover this plugin has that feature as an extra to the “main” functionality which is adding image rollover (auto-switching between two designated images when the mouse hovers over the image).  Much more control over the order of the images AND no code edits to core CubeCart

Ian

Link to comment
Share on other sites

  • 1 month later...

I think I found a solution, even if it's a bit cumbersome.  Before you begin, have a list of the images you want for your product in the order you want them to appear. For example: 

  1. Image 1 (primary image)
  2. Image 2
  3. Image 3
  4. Image 4

Go to your product page and then to the image tab.

Remove all of your images (except the image you want to be starred for the primary image) from the product. Click "Save and Reload"

Then, look at your list, and going in REVERSE order (begin with the image you want to appear last), click the checkbox of the image that is last on your list (In the example, this would be Image 4).

Click "Save and Reload". This will add the image to top of the list, but after the primary image.

Then add the next to last image (Image 3, in the example). Click "Save and Reload" to add the image to the top of the list, but after the primary image.

Keep doing this until you have added all of the images (all the way to Image 2)

 

As I said, cumbersome, but you can do it in the product page of the admin console.

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi Dnhart29,

Thank you for the suggestion, unfortunately I have over 2,700 products with roughly 7 images each :-(

So I am looking for an automated option. I am nearly there with a mod from Havenswift so keeping my fingers crossed with that

But thanks for having a look and spending the time to reply

Regards Gary

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...