Site logo

Archived topic

Image Size - Use WooCommerce generated size?

3 replies · Started by Antoine on June 24, 2021

Viewing posts 1–4 of 4

Hi,
When adding an image in the Wordpress editor (classic or Gutenberg), the standard image sizes are: Thumbnail, Medium, Large, Full.

Now, WooCommerce also create different image sizes per Customize > WooCommerce > Product Images.

The question is: is it possible to add these WooCommerce image sizes into the Wordpress editor? (e.g. Thumbnail, Medium, Large, Full, WooCommerce Thumbnail, WooCommerce Main Image)

I am aware it's possible to add custom size(s) (per https://generatepress.com/forums/topic/gallery-grid-perfectly-square-same-size-images/#post-600638), but the idea here is to prevent creating more copies of the images in the database.

Thanks!

This snippet worked perfectly:

// Make custom sizes selectable from WordPress admin.
function custom_image_sizes( $size_names ) {
    $new_sizes = array(
        'woocommerce_thumbnail' => __( 'WooCommerce Thumbnail (300x300 cropped)'),
    );
    return array_merge( $size_names, $new_sizes );
}
add_filter( 'image_size_names_choose', 'custom_image_sizes' );

Thanks for your EXCELLENT support! :)

Awesome - glad to be of help :)

This archived topic is closed to new replies.