Registers an image size for the post thumbnail.
Description
See also
- add_image_size(): for details on cropping behavior.
Parameters
$width
intrequired- Image width in pixels.
$height
intrequired- Image height in pixels.
$crop
bool|arrayoptional- Image cropping behavior. If false, the image will be scaled (default).
If true, image will be cropped to the specified dimensions using center positions.
If an array, the image will be cropped using the array to specify the crop location:0
stringThe x crop position. Accepts'left'
'center'
, or'right'
.1
stringThe y crop position. Accepts'top'
,'center'
, or'bottom'
.
Default:
false
Source
function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
add_image_size( 'post-thumbnail', $width, $height, $crop );
}
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |
Default Usage
To be used in the current theme’s
functions.php
file.Crop Mode
Set the default Post Thumbnail size by resizing the image proportionally (that is, without distorting it):
Set the default Post Thumbnail size by cropping the image (either from the sides, or from the top and bottom):
Set the default Post Thumbnail size by cropping the image from top left:
Set the default Post Thumbnail size by cropping the image from the center:
Note:
This function will not resize your existing featured images. To regenerate existing images in the new size, use the Regenerate Thumbnails plugin.
I guess this just stopped working in the new Gutenberg editor environment. ¯\_(ツ)_/¯
At least with the below, totally standard usage, the function doesn’t have any effect on the way a post thumbnail gets displayed on a post edit screen.