I work on slider for woocommerce product gallery and I don't use/need the generated thumbnails, because I use "dots" for navigation and I want to hide/unload the generated thumbnails by woocommerce gallery.
Firstly, I put this in my theme functions.php file:
remove_theme_support( 'wc-product-gallery-slider' );
And actually, I just put "display:none" in my css file and I make this for the product-thumbnails.php :
// Note: `wc_get_gallery_image_html` was added in WC 3.3.2 and did not exist prior. This check protects against theme overrides being used on older versions of WC.
if ( ! function_exists( 'wc_get_gallery_image_html' ) ) {
return;
}
global $post, $product;
$attachment_ids = $product->get_gallery_image_ids();
if ( $attachment_ids && $product->get_image_id() ) { ?>
<div class="slider product-responsive-thumbnail" id="product_thumbnail_<?php echo esc_attr( $post->ID ); ?>">
<?php foreach ( $attachment_ids as $attachment_id ) { ?>
<div class="thumbnail-wrapper">
<?php echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', wc_get_gallery_image_html( $attachment_id ), $attachment_id ); // phpcs:disable WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
</div>
<?php
} ?>
</div>
<?php
}
?>
I would like to disable the generation of thumbnails and its display completely to optimize the loading of my page!
I know that I can totally delete the contents of the file "produtc-thumbnails.php" but it is a bit raw method and I would like to know if this is possible with another less raw method
As @7uc1f3r suggested to me,
First simple solution. Mask in the woocommerce-general.css file like this:
.woocommerce div.product div.images .flex-control-thumbs {
overflow: hidden;
zoom: 1;
margin: 0;
padding:0;
display:none; /* this hide the thumbnails */
}
Second solution, put " false " in the product-thumbnails.php
if ( ! function_exists( 'wc_get_gallery_image_html' ) ) {
return;
}
global $post, $product;
$attachment_ids = false; // This disable the thumbnails
And voilà, now it's up to you to choose the method you want to keep.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.