set_post_thumbnail_size() WordPress Function

The set_post_thumbnail_size() function sets the default post thumbnail size for the site. This function should be called after the theme has been setup.

set_post_thumbnail_size( int $width, int $height, bool|array $crop = false ) #

Registers an image size for the post thumbnail.


Description

Top ↑

See also


Top ↑

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


Top ↑

More Information

  • To register additional image sizes for Featured Images use: add_image_size().
  • To enable featured images, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file. See also Post Thumbnails.
  • This function will not resize your existing featured images. To regenerate existing images in the new size, use the Regenerate Thumbnails plugin.

Top ↑

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More