0

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.

1 Answer 1

0

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 );
?>
0

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.