0

I am wondering if I could change the size of one specific catalog product image.

I have many products with the same size (catalog images-not single product images, not even product thumbnails) and I want to change the size of a specific product, in order to be smaller than the other catalog images.

How can I do that?

2 Answers 2

1

You can use the single_product_archive_thumbnail_size filter to change which image size is used for a particular product:

function wpse_287488_product_thumbnail_size( $size ) {
    global $product;

    if ( $product->get_id() === 123 ) {
        $size = 'medium';
    }

    return $size;
}
add_filter( 'single_product_archive_thumbnail_size', 'wpse_287488_product_thumbnail_size' );

Just replace medium with the registered image size you want to use. See this codex article for an overview of image sizes and how to register your own.

0

Without going into too much detail..

global $product;

if($product->ID == '21'):
the_post_thumbnail('size');
else:
<default code for displaying product thumb>
endif;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.