Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Setting the 1st Gallery Image as Default Drop down image
- This topic has 7 replies, 2 voices, and was last updated 4 years, 1 month ago by
Ernest Marcinko.
-
AuthorPosts
-
April 12, 2022 at 4:11 am #37484
lombardibenny
ParticipantHi we just bought your plugin, I have spent many hours trying to configure the search to retrieve the first gallery image as the drop down image but to no avail. I was wondering if you would know what selector to use or if it’s even possible to get the Ajax to retreive the first image in the gallery. See: https://sugatsune.ca/product/3-way-adjustable-concealed-hinge-for-cladded-doors-black
Thank you for taking the time, please let us know what we are doing wrong or if its possible to set that image.
Please example of what we are trying to do: https://imgur.com/a/ojW8U1N
Thanks
April 12, 2022 at 3:10 pm #37498Ernest Marcinko
KeymasterHi,
That is a tough one, it depends on how that gallery is appended to the actual content. I assume it might be a shortcode of some sort. In that case, try turning on this option, to see if it changes anything.
April 12, 2022 at 4:15 pm #37502lombardibenny
ParticipantHi no I tried that, the previous developer built the site in ACF I saw this in your troubleshooting guide and gave it try. Doesn’t work unfortunately. I have been trying to get it to work using the custom fields containing image term. Am I barking down the wrong tree here?
Searching HES I found the the search actually draws in the first galley image sometimes, but it doesn’t do it consistently for all. Is there a way to pinpoint the setting?
This product is showing first image gallery, See: https://staging5.sugatsune.ca/product/glass-door-bracket-for-hes3d-9-3/
Search: HESThank you for your time.
April 13, 2022 at 4:31 pm #37516Ernest Marcinko
KeymasterWell, those may not be coming from the actual gallery, the imge URLs are different in the page source, and in the search.
Can you check if on any of those posts there is a featured image set perhaps? Maybe that is the one, the plugin actually fetched.If the option I suggested did not work, then then this may not be possible. I suspect the gallery may not be rendered only on an actual pageview, so the plugin can’t “see” the images in the page source.
I can double check the configuration if you want to, however I could not find a way to log-in. Is there a URL I need to visit for that?
The custom field you tried there will not work that way. The field has to be an image field, or a text field containing the image. I guess the gallery is some sort of a section/object or a complex repeater field of some sort.
April 13, 2022 at 9:13 pm #37527lombardibenny
ParticipantSorry Ernest the log in url is: https://staging5.sugatsune.ca/lampstaff/
(credentials are attached at the top)
Please can you check for us. I am will to pay you for your time to get this to work.April 14, 2022 at 2:56 pm #37533Ernest Marcinko
KeymasterI think I actually managed to find a possible solution. I did a bit of research and placed this custom code to the functions.php file in your theme directory:
// Ajax Search Pro - Getting the first WooCommerce gallery image as the featured image add_filter( 'asp_results', 'asp_get_woocommerce_gallery_first_image', 10, 1 ); function asp_get_woocommerce_gallery_first_image( $results ) { foreach ($results as $k=>&$r) { if ( isset($r->post_type) && $r->post_type == 'product' ) { $product = wc_get_product($r->id); $attachment_ids = $product->get_gallery_image_ids(); if ( isset($attachment_ids[0]) ) { $r->image = wp_get_attachment_url( $attachment_ids[0] ); } } } return $results; }From what I can see, where the gallery is available, I am seeing the first image as the results featured image.
April 14, 2022 at 6:14 pm #37539lombardibenny
ParticipantFANTASTIC! Thank you so much. We will make sure to review you on Code Canyon. Really appreciate your work.
April 15, 2022 at 8:57 am #37541Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.