set_post_thumbnail_size( int $width, int $height, bool|array $crop = false )
Registers an image size for the post thumbnail.
Description Description
See also See also
- add_image_size(): for details on cropping behavior.
Parameters Parameters
- $width
-
(int) (Required) Image width in pixels.
- $height
-
(int) (Required) Image height in pixels.
- $crop
-
(bool|array) (Optional) Whether to crop images to specified width and height or resize. An array can specify positioning of the crop area.
Default value: false
Source Source
File: wp-includes/media.php
function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
add_image_size( 'post-thumbnail', $width, $height, $crop );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Default Usage
To be used in the current theme’s
functions.phpfile.function wpdocs_setup_theme() { add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 150, 150 ); } add_action( 'after_setup_theme', 'wpdocs_setup_theme' );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.