garywhitling Posted February 3, 2018 Share Posted February 3, 2018 Hi, I was wondering if anyone is aware of how to arrange the images within the gallery area on the product page in to a certain order. For example drag and drop in to position from within the admin area or alphabetically within the code. Quote Link to comment Share on other sites More sharing options...
bsmither Posted February 3, 2018 Share Posted February 3, 2018 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. Quote Link to comment Share on other sites More sharing options...
garywhitling Posted February 3, 2018 Author Share Posted February 3, 2018 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 Quote Link to comment Share on other sites More sharing options...
bsmither Posted February 3, 2018 Share Posted February 3, 2018 I can envision the jQuery plugin FileTree acquiring the ability to have an arbitrary sort. I think that would be the only way. Quote Link to comment Share on other sites More sharing options...
havenswift-hosting Posted February 4, 2018 Share Posted February 4, 2018 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 Quote Link to comment Share on other sites More sharing options...
garywhitling Posted February 4, 2018 Author Share Posted February 4, 2018 Hi Ian, Cool, I will give it and go Cheers Gary Quote Link to comment Share on other sites More sharing options...
dnhart29 Posted March 5, 2018 Share Posted March 5, 2018 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: Image 1 (primary image) Image 2 Image 3 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. Quote Link to comment Share on other sites More sharing options...
garywhitling Posted March 18, 2018 Author Share Posted March 18, 2018 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.