- This topic has 3 replies, 2 voices, and was last updated 6 months, 1 week ago by David.
August 27, 2020 at 7:06 am #1420373Sammy
On my single product page, my 2000x2000px uploaded product image is being used. Size’wise a huge load on the page, looks like this:
<div class="woo-gallery-stack hide-on-mobile"> <img src="product.png" alt="" title="product"> </div>
Is it possible to use the WP generated IMG thumbnails as main product image? Just like how it does on the frontpage (listing newest products etc.):
<img width="400" height="400" src="product-400x400.png" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" alt="" loading="lazy" srcset=" product-400x400.png 400w, product-300x300.png 300w, product-1024x1024.png 1024w, product-150x150.png 150w, product-768x768.png 768w, product-1536x1536.png 1536w, product-600x600.png 600w, product-100x100.png 100w, product.png 2000w " sizes="(max-width: 400px) 100vw, 400px" />
Tried to see if I could unhook the image and possibly re-add it, but something like:
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
Has no effect.August 27, 2020 at 7:44 am #1420439DavidStaffCustomer Support
the Niche site adds a hook element named Gallery Stack, found in Appearance > Elements.
It uses PHP to output the stack. Currently the best i can do is help change the size of the image it loads – look for these two lines:
$attachment = wp_get_attachment_image_src( $attachment_ids, 'full' ); $image_url = wp_get_attachment_url( $product_image_id, 'full' );
fullto the attachment size you want to use.August 27, 2020 at 8:09 am #1420632Sammy
It works. For reference it seems possible to use the following:
– ‘thumbnail’, ‘small’, ‘medium’, ‘large’, ‘full’
Noone of those hit the sweatspot width’wise for my layout. (medium was too small and large too big)
But seems it also accepts specific integer which relates to whatever thumbnail size is generated within WP.
I noticed a 600x600px thumbnail was generated, so I could do:
$attachment = wp_get_attachment_image_src( $attachment_ids, array( 600, 600 ) ); $image_url = wp_get_attachment_url( $product_image_id, array( 600, 600 ) );August 27, 2020 at 8:15 am #1420651DavidStaffCustomer Support
Thats correct, woo creates the 600×600 image ( based on what you set in Customizer > Woocommerce > Product Images ).
You can also register your own sizes if needed:
Glad to be of help
- You must be logged in to reply to this topic.