WordPress let you choose between thumb
medium
large
and full
size when uploading and inserting an image into a post or a page.
The meaning of full
is obvious. But how WordPress set size for thumb
(I seem to remember 150×150 and in some cases 200×200), medium
and large
?
Are there fixed sizes or can they vary according to the original image sizes?
2 Answers
The defaults are Thumbnail 150x150
, Medium 300x300
, and Large 1024x1024
. The fixed values can be changed in the admin dashboard under Settings > Media. You can also change them in your theme’s functions.php:
update_option( 'thumbnail_size_w', 160 ); // Set Thumbnail width - default 150
update_option( 'thumbnail_size_h', 160 ); // Set Thumbnail height - default 150
update_option( 'thumbnail_crop', 1 ); // Set Crop mode - 0 Soft, 1 Hard
The above sets Thumbnail to 160×160 and Hard crop mode (vs Soft proportional crop mode with a value of 0). Hard crop will actually crop the image to fit the width and height, where as Soft crop will resize the image to fit within the dimensions. I.e. a 800×600 with soft crop would end up being 160×120 instead of 160×160 with Hard crop, but the full down-sized image would still be visible.
You can also create additional custom image sizes using the add_image_size() function, i.e.
add_image_size( 'home-mini', 50, 50, TRUE ); // Custom Name, Width, Height, Crop mode
For more information, see the Codex.