1

I wonder if you can help me track down why all my images are being cropped to a 300px size that I've not specified anywhere at all. I know from some digging in the past that WordPress introduced a default size of 768px and basically hid it from us, now I'm wondering if they (or WooCommerce - this is a WooCommerce site) also have a hidden size of 300px.

That 768px size was called medium_large and you would unset it like so:

function mytheme_filter_image_sizes($sizes) {  
    unset( $sizes[ 'medium_large' ] );
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'mytheme_filter_image_sizes' ); 

Has anyone come across this extra 300px image and how did you unset it? Googling this has proved useless.

Here's my code for the image sizes being used in this theme:

add_theme_support( 'post-thumbnails' );

// Set our preferred default image sizes
set_post_thumbnail_size( 960, 960, true );

update_option( 'thumbnail_size_w', 240 );
update_option( 'thumbnail_size_h', 240 );
update_option( 'thumbnail_crop', 1 );
update_option( 'medium_size_w', 720 );
update_option( 'medium_size_h', 720 );
update_option( 'large_size_w', 1440 );
update_option( 'large_size_h', 1440 );

// Custom new sizes for the srcset
add_image_size( 'mytheme-hd-img', 1920, 1920);
add_image_size( 'mytheme-epic-img', 2400, 2400);

And for WooCommerece:

$catalog = array(
    'width'     => '360',
    'height'    => '360',
    'crop'      => 1        // true
);
$single = array(
    'width'     => '720',
    'height'    => '720',
    'crop'      => 0        // false
);
$thumbnail = array(
    'width'     => '240',
    'height'    => '240',
    'crop'      => 1        // true
);
// Image sizes
update_option( 'shop_catalog_image_size', $catalog );
update_option( 'shop_single_image_size', $single );
update_option( 'shop_thumbnail_image_size', $thumbnail );
  • 300 is medium and has been there forever, and can be changed in Settings > Media. – Jacob Peattie Dec 6 '17 at 10:26
  • @JacobPeattie I've specified my sizes exactly as I've done in other themes. I'm still getting 300px. I will include them in the original post. – LubosB Dec 6 '17 at 10:29
  • Are these images that were already uploaded? Sizes won't get applied retroactively. – Jacob Peattie Dec 6 '17 at 10:29
  • @JacobPeattie I've used regenerate and uploaded a few new images to observe the behaviour. Must be an error somewhere. – LubosB Dec 6 '17 at 10:32
  • It appears to be a WooCommerce size. I've disabled WooCommerce and uploaded a new image to a page, and it's obeying my WordPress size settings (240, 720, 1440). – LubosB Dec 6 '17 at 13:04
1

Updated Answer

After doing more testing, the 300px size only gets generated when I have the official WooCommerce Brands plugin activated.

So 300px is the default WooCommerce image size when the standard sizes go undefined. See wc_get_image_size() in \includes\wc-core-functions.php.

It seems that at some point WC must have filled in the blank of a missing size and that setting got used.

My temporary solution is to deactivate the WooCommerce Brands plugin. Obviously this isn't viable so I may have to report this bug...

Bug has been reported.

I talked with WooCommerce support and they've been able to replicate the issue and have created a bug report.

1

I work for WooCommerce - just wanted to give everyone a heads up that this has been reported. While I don't have an ETA on the fix, I'll try to post here if it's timely (don't want to resurrect dead threads), but keep an eye on the Brands Changelog just in case.

Thanks for bringing it up! :)

UPDATE: December 13, 2017

So after our dev team looked through this, it's actually added by design. The 300px image is used for the Brand listing pages and functions associated with that, which is built for 300px images.

Although that means it's not considered a "bug", it's something that could certainly be improved. I'll look into adding an image display setting that would allow you to change the size of the brand image that's used. Keep an eye on the changelog - hopefully I'll be able to get something through (once I eventually find a few minutes to code).

  • You work for WooCommerce. There are tons of WooCommerce related questions here on a daily basis. Get to work my friend. – Christine Cooper Dec 6 '17 at 16:16
  • @ChristineCooper I most certainly work - in the official support channels we offer for our products. That more than fills the day. – Danny Santoro Dec 13 '17 at 18:35
  • that would be great if it could use the existing theme's sizes... when you have to regenerate 3400 product images and new products are being added all the time, those extra files really add up. – LubosB Dec 23 '17 at 11:02
  • @Danny Santoro I noticed today that the image size is still being generated even after the latest update. I've submitted a ticket at the official site. Maybe it has something to do with the latest updates to WooCommerce core image sizes. – LubosB Feb 11 '18 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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