Change WooCommerce Image Size in One Product CAtegory
I have one Product Category that needs to have 300 x 300px uncropped thumbnail images. All of the other products have 300 x 300px, cropped thumbnails. This would be on the Shop page and the Category Pages. The category is for Books and the cropped image cuts off the top and bottom of the book cover. All of the other product categories look best with a square cropped image.
I added this code to my functions.php file, but it has no effect. Since the default WP medium image is already 300 x 300px, uncropped on the site I used "medium" as $size. I searched for more than an hour and can't find much else that is helpful. Am I on the right track with this code, or not? Any advice? Thank you!
/* SetImage Sizes on Category Pages for Books */
if ( is_product_category( '2295' )) {
// different size for one category
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'custom_loop_product_thumbnail', 10 );
function custom_loop_product_thumbnail() {
global $product;
$size = 'medium';
$image_size = apply_filters( 'single_product_archive_thumbnail_size', $size );
return $product ? $product-get_image( $image_size ) : '';
}
}
Topic woocommerce-offtopic thumbnails Wordpress
Category Web