Woocommerce product images not lazyloaded
-
Hello Florian,
I noticed that the woocommerce product images on my website are not lazyloaded. See here: https://hautlescours.fr/produit/olivier-regin/ for the image at the top.
Though they have a “wp-post-image” class and data-src attribute. I must admit I don’t know how my theme handles those images.
Thanks for your help,
Nicolas
If this helps here is some code I had added to my functions.php when I created the website 3 years ago, following the adivce on a blog, but I am not sure how useful it is:
//this line removes the existing Woocommerce codes remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); //This line adds a new action which adds a tag BEFORE the woocommerce "stuff" add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10); //This line adds a new action which adds a tag AFTER the woocommerce "stuff" add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10); //This line adds a new css section tag called "woogrid" BEFORE the woocommerce "stuff" function my_theme_wrapper_start() { echo '<section id="woogrid">'; } //This line ends the new "woogrid" section function my_theme_wrapper_end() { echo '</section>'; } /****Afficher la taille des images dans la librairie de WordPress**/ add_filter('manage_upload_columns', 'size_column_register'); function size_column_register($columns) { $columns['dimensions'] = 'Dimensions'; return $columns; } add_action( 'after_setup_theme', 'woocommerce_support' ); function woocommerce_support() { add_theme_support( 'woocommerce' ); } add_action('manage_media_custom_column', 'size_column_display', 10, 2); function size_column_display($column_name, $post_id) { if( 'dimensions' != $column_name || !wp_attachment_is_image($post_id)) return; list($url, $width, $height) = wp_get_attachment_image_src($post_id, 'full'); echo esc_html("{$width}×{$height}"); } // Change number or products per row to 2 in Woocommerce add_filter('loop_shop_columns', 'loop_columns'); if (!function_exists('loop_columns')) { function loop_columns() { return 2; // 2 products per row } } // Display 24 products per page. Goes in functions.php /*add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 4;' ), 20 );*/ /** * Change number of products that are displayed per page (shop page) */ add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 ); function new_loop_shop_per_page( $cols ) { // $cols contains the current number of products per page based on the value stored on Options -> Reading // Return the number of products you wanna show per page. $cols = 12; return $cols; } //Les mininatures d'un produit Woocommerce font 200x200 add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) { return array( 'width' => 200, 'height' => 200, 'crop' => 0, ); } );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Woocommerce product images not lazyloaded’ is closed to new replies.