0

I am working with WooCommerce product image. My code is like below

if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ):
    function woocommerce_template_loop_product_thumbnail() {
        global $product;
        $image = wp_get_attachment_image_src( get_post_thumbnail_id( $product->get_id()), 'medium');
        echo '<a href="'.get_permalink($product->get_id()).'"><img src="'.$image[0].'" /></a>';
    }
endif;

But I am getting a BIG image.

I am getting a good size image using below code.

if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ):
    function woocommerce_template_loop_product_thumbnail() {
        echo woocommerce_get_product_thumbnail();
}
endif;

How can I get a good size image using get_post_thumbnail_id() ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.