• Resolved keneso

    (@keneso)


    I am trying to customize Storefront theme by creating a child, I am trying to set thumbnail sizes, and it seems there is one for all, whereas I’d like to have different sizes depending on the “object”, i.e. category size, and product size.

    I have tried the following from the WC dev docs in the child functions.php and it does not work, I found another solution that does work in setting the 3 sizes, but like said I’d like to have the product thumbnail image different than the category thumbnail image.

    add_theme_support( 'woocommerce', array(
    'thumbnail_image_width' => 50,
    'gallery_thumbnail_image_width' => 50,
    'single_image_width' => 500,
    ) );

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @keneso

    The code you’re trying to use is for setting the main image dimensions for your products, and it doesn’t differentiate between product and category images.

    You’ll need to use a different approach to achieve different thumbnail sizes for product and category. You can try using the woocommerce_get_image_size_thumbnail filter for product images and subcategory_archive_thumbnail_size filter for category images.

    I hope this helps! If you have any other questions, feel free to ask.

    Thread Starter keneso

    (@keneso)

    Hi

    Here is what I put in functions.php

    add_filter( 'woocommerce_get_image_size_thumbnail', function( $size ) {
    return array(
    'width' => 450,
    'height' => 450,
    'crop' => 0,
    );
    } );
    
    add_filter( 'subcategory_archive_thumbnail_size', function( $size ) {
    return array(
    'width' => 50,
    'height' => 50,
    'crop' => 0,
    );
    } );

    I added first the woocommerce_get_image_size_thumbnail, and it seemed to work, then I added subcategory_archive_thumbnail_size and the image size is shown at 600px by 600px when inspecting the element, the actual display by measuring it is 230×230, and before the image being displayed I get a lot (I mean really a lot) of lines like the following – I have wp_debug set to true in my local environment. different keys (0 and 1), and lines reported.

    Warning: Undefined array key 0 in C:\path-to-wp\wp-includes\media.php on line 795

    I have put the same function.php on a live test here: afzdesign dot com slash demo slash kamaleu (please remove blanks, and change dot and slashes)

    Thank you

    Thread Starter keneso

    (@keneso)

    hrn1995 (woo-hc)

    (@aguinaldodarla)

    Hi @keneso

    That’s great to hear that everything is working now. You did well in finding the solution, thanks for sharing it with the community.

    I’m going to mark this thread as resolved, but please don’t hesitate to start a new topic if you have any more questions down the line.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘thumbnail sizing’ is closed to new replies.