Woocommerce产品缩略图大小

I am trying to get all small medium large and full thumbnail sizes in the SHOP page of woocommerce. I am using the following code in woocommerce.php (duplicate of page.php) to display all products

<?php woocommerce_content(); ?>

Next I have put the following code in functions.php but all in vain

<?php
/**
 * Hook in on activation
 */

/**
 * Define image sizes
 */
function yourtheme_woocommerce_image_dimensions() {
    global $pagenow;

    if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) {
        return;
    }

    $thumbnail = array(
        'thumbnail' , 'medium' , 'large' , 'full'
    );
    $index = array_rand($sizes);
    // Image sizes
        // Single product image
    update_option( 'shop_thumbnail_image_size', $sizes[$index] );   // Image gallery thumbs
}

add_action( 'after_switch_theme', 'yourtheme_woocommerce_image_dimensions', 1 );

?>

I am new to woocommerce and I wish to achieve a masonry layout with these different thumbnail sizes. Any help would be greatly appreciated. Thank You in advance.

Try following code:

<?php
/**
 * Hook in on activation
 */

/**
 * Define image sizes
 */
function yourtheme_woocommerce_image_dimensions() {
    global $pagenow;

    if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) {
        return;
    }

    $thumbnail = array(
        'thumbnail' , 'medium' , 'large' , 'full'
    );
    $index = array_rand($thumbnail);
    // Image sizes
        // Single product image
    update_option( 'shop_thumbnail_image_size', $thumbnail[$index] );   // Image gallery thumbs
}
add_action( 'after_switch_theme', 'yourtheme_woocommerce_image_dimensions', 1 );
?>