How to override an image size in WooCommerce

Product single

1
2
3
4
5
<?php add_filter( 'woocommerce_get_image_size_single', function( $size ) { return array( 'width' => 400,
        'height' => '',
        'crop'   => 0,
    );
} );
1
2
3
4
5
6
7
add_filter( 'woocommerce_get_image_size_single', function( $size ) {
    return array(
        'width'  => 500,
        'height' => 500,
        'crop'   => 1,
    );
} );

Thumbnail (for shop and category pages)

1
2
3
4
5
6
7
add_filter( 'woocommerce_get_image_size_thumbnail', function( $size ) {
    return array(
        'width'  => 500,
        'height' => 500,
        'crop'   => 1,
    );
} );

Gallery

1
2
3
4
5
6
7
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
    return array(
        'width'  => 400,
        'height' => 400,
        'crop'   => 1,
    );
} );