Skip Navigation

[Resolved] Image not displayed after using filter tool

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user was using the woocommerce gallery in a view of products, the images were not displaying after AJAX filtering.

Solution:
The view is generating WooCommerce galleries instead of only the product image, using the following shortcode:

[wpv-woo-product-image size="woocommerce_thumbnail"]

The galleries are initialized on the first load, but after subsequent AJAX requests(after filtering) the galleries are not initialized, we need to add custom Javascript code to do it. I added the following code to trigger galleries initialization after filtering with AJAX or after AJAX pagination. http://prntscr.com/xswedy

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated js_event_wpv_pagination_completed', function( event, data ) {
    jQuery( '.woocommerce-product-gallery' ).each( function() {
      jQuery( this ).wc_product_gallery();
    } );
});

Relevant Documentation: https://toolset.com/documentation/programmer-reference/adding-custom-javascript-code-to-views-that-use-ajax/

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by pierreD-4 4 years ago.

Assisted by: Jamal.

Author
Posts
#1916103
Capture.PNG

I am trying to: to display product images

Link to a page where the issue can be seen: Homepage

I expected to see: the products and their picture

Instead, I got: the products but the image is not displayed

#1916321

Hello and thank you for contacting the Toolset support.

Please check if this issue appears when:
- Only Toolset plugins are activated. It will tell us if there is an interaction issue with another plugin.
- The theme is set to a WordPress default like Twenty-Twenty. It will tell us if there is an interaction issue with your theme.
If the problem disappears, start activating one at a time to track where the incompatibility is produced.

If this does not help, allow me temporary access to check your website closely. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1922917

Thank you for the credentials.

The view is generating WooCommerce galleries instead of only the product image, using the following shortcode:

[wpv-woo-product-image size="woocommerce_thumbnail"]

The galleries are initialized on the first load, but after subsequent AJAX requests(after filtering) the galleries are not initialized, we need to add custom Javascript code to do it. I added the following code to trigger galleries initialization after filtering with AJAX or after AJAX pagination. hidden link

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated js_event_wpv_pagination_completed', function( event, data ) {
	jQuery( '.woocommerce-product-gallery', data ).each( function() {
      jQuery( this ).wc_product_gallery();
    } );
});
#1923217
probleme images.PNG

Hi Jamal,

Thank you for your quick reply! Unfortunately it is still not working, is there something more I should do to make it work ?

#1923379

Sorry, I copied the wrong code. Now it is fixed:

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated js_event_wpv_pagination_completed', function( event, data ) {
	jQuery( '.woocommerce-product-gallery' ).each( function() {
      jQuery( this ).wc_product_gallery();
    } );
});
#1926433

Everything is working ! Thank you!