I want to add a custom image size that is cropped, like this:

add_image_size( 'large-cropped', 700, 300, true );

It works fine. The only problem is that if the image size is for example 500×400, then it will create an image that is 500×300.

I only want it to create an image if the width is at least 700 pixels width.

1 Answer
1

You will need to do a check for the image size before you add the add_image_size in that case. You can use wp_get_attachment_metadata() to find the size of the image. https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *