Hello guys,
Working on some cleaning up here and I’d like to establish a more comprehensive approach to our image sizes as we now have 16 different sizes registered and we hardly use that much.
We have…
- Original image (WP)
- Thumbnail - (150x150) (WP)
- Medium - (300x300) (WP)
- Large - (1024x1024) (WP)
- nh-medium - (500x500) (Custom)
- entry - (1184x9999) (Pro)
- entry-cropped - (1184x662) (Pro)
- entry-fullwidth - (1184x9999) (Pro)
- entry-cropped-fullwidth - (1184x662) (Pro)
- woocommerce_thumbnail - (300x300) (WooCommerce)
- woocommerce_single - (600x0) (WooCommerce)
- woocommerce_gallery_thumbnail - (100x100) (WooCommerce)
- shop_catalog - (300x300) (Pro)
- shop_single - (600x0) (Pro)
- shop_thumbnail - (100x100) (Pro)
- wc_order_status_icon - (32x32) (WooCommerce Plugin)
- post-thumbnail - (100x100) (Pro?) – Not reported in Toolset but displayed in TinyPNG sizes
Remark #1: The WooCommerce image size name has changed and now uses “woocommerce_” prefix instead of “shop_”. I’m not sure if this is how X overwrite WooCommerce’s image sizes but I believe X should be using the same image size name. Has this already been addressed in the coming release candidate?
Reference: https://iconicwp.com/blog/manage-woocommerce-product-image-sizes-3-3/#comment-273
Remark #2: Something odd seems to be happening with the “woocommerce_single” / “shop_single” sizes as their height returns 0. Is this expected?
This list was pulled from Toolset when building a query and requesting the post featured image as you can select which image size to use. TinyPNG also report a height of “?”
Remark #3: We have tried to overwrite X logic for the image size without luck. Our blog posts have been heavily customized. We always use a fullwidth layout for blog posts and the featured image height is fixed. We’d like to remove unused image sizes and use a fixed image size (without the padding logic applied).
A) Can we safely remove “entry” and “entry-cropped”? Should these be used anywhere, will it automatically fallback on “entry-fullwidth-cropped” or another existing image size? We only wish to use “entry-fullwidth-cropped”.
B) I tried to remove the sizes we don’t use but I’m not sure if it’s working. Toolset still displays the sizes after I add the following code in our child-theme functions.php:
// Add custom image size
if ( function_exists( 'add_image_size' ) ) {
add_image_size('nh-medium', 500, 500);
//add_image_size('entry', 0);
//add_image_size('entry-cropped', 0);
add_image_size('entry-fullwidth', 1200, 9999,false);
add_image_size('entry-cropped-fullwidth', 1200, 630, true);
}
if ( function_exists( 'remove_image_size' ) ) {
remove_image_size('entry');
remove_image_size('entry-cropped');
remove_image_size('wc_order_status_icon');
}
function nh_filter_image_sizes( $sizes) {
unset( $sizes['entry']);
unset( $sizes['entry-cropped']);
unset( $sizes['wc_order_status_icon']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'nh_filter_image_sizes');
The commented out lines is something I tried after reading this: Change theme featured images and thumbnail sizes
Remark #4: I used to restore the WooCommerce image size settings using this snippet:
add_filter('init', 'remove_product_settings_filter');
function remove_product_settings_filter() {
remove_filter('woocommerce_product_settings', 'x_woocommerce_remove_plugin_settings');
}
It looks like this doesn’t work anymore, could you let me know how to update it?
Remark #5: The image size “post-thumbnail” doesn’t look like a standard image size (see the_post_thumbnail()). If this is indeed added by Pro, can you confirm we can simply replace it with a new size as such?
add_image_size('post-thumbnail', 150, 150, true);
Remark #6: As you can see in the snippet provided in Note #3, I have tried to change the “entry-cropped-fullwidth” image size to 1200x630 but it didn’t change anything. How can we replace that?
Thank you!