Can someone show how we can use this code with Woocommerce?
I am using this code from
Woocommerce product gallery images are showing as full size images instead of thumbnail
but not working. (maybe, I just don't know how to use it )
add_action('woocommerce_shop_loop_item_title','wps_add_extra_product_thumbs', 5);
function wps_add_extra_product_thumbs() {
if (is_product()) {
global $product;
$attachment_ids = $product->get_gallery_image_ids();
echo '<div class="product-thumbs">';
foreach( array_slice( $attachment_ids, 0,3 ) as $attachment_id ) {
$thumbnail_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail' )[0];
echo '<img class="thumb" src="' . $thumbnail_url . '">';
}
echo '</div>';
}
}
My Answer:
> You can use the following code to show product gallery images as full-size images in WooCommerce:
php
add_action('woocommerce_before_single_product_summary', 'wps_add_extra_product_thumbs', 5);
function wps_add_extra_product_thumbs() {
global $product;
$attachment_ids = $product->get_gallery_image_ids();
if ($attachment_ids) {
foreach ($attachment_ids as $attachment_id) {
$image_link = wp_get_attachment_url($attachment_id);
echo '
';
}
}
}
This code will display the product gallery images as full-size images on the single product page in WooCommerce. Just add this code to your theme's functions.php file or a custom plugin file.
Rate this post
5 of 5 based on 8404 votesComments