I'm using WP Job Manager, and would like user-uploaded logos to be resized and positioned to fit within a fixed height and width. Currently, my settings are at:
When I am uploading the following image (250x169):
This is what I get:
But what I want to have the image resized to fit a fixed width and height of let's say 150x150, like so:
I tried unchecking the "crop thubmnail to exact dimensions..." in settings, the image is then just resized (like to 150x68, not 150x150 without cropping)
I tried adding the following to my theme's functions.php:
add_image_size( '150x150-crop', 150, 150, false );
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150, true );
Nothing makes a difference. Any ideas?
I'm using WP Job Manager, and would like user-uploaded logos to be resized and positioned to fit within a fixed height and width. Currently, my settings are at:
When I am uploading the following image (250x169):
This is what I get:
But what I want to have the image resized to fit a fixed width and height of let's say 150x150, like so:
I tried unchecking the "crop thubmnail to exact dimensions..." in settings, the image is then just resized (like to 150x68, not 150x150 without cropping)
I tried adding the following to my theme's functions.php:
add_image_size( '150x150-crop', 150, 150, false );
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150, true );
Nothing makes a difference. Any ideas?
Share Improve this question asked Jun 9, 2019 at 8:50 MARMAR 1091 silver badge4 bronze badges1 Answer
Reset to default 0What you're apparently asking for isn't possible. WordPress will never add white space to an image to make it fit a certain size. This is what cropping means. Cropping will always remove (i.e. crop) some of the image so that it fits a certain size. As far as I am aware, there is no tool that ever refers to adding space as 'cropping', so WordPress' behaviour is the expected behaviour.
So your only options are to resize the image, keeping the proportions (your 3rd image), or removing some of the image to fit the desired dimensions (your 2nd example).
If you want images to fill specific dimensions without being cropped, you will either need to upload them at the desired dimensions originally, or if they're being used in a specific way in a specific template, use CSS to position the uncropped images the way you want.