set_post_thumbnail_size

Registers an image size for the post thumbnail.

Description

set_post_thumbnail_size( (int) $width = 0, (int) $height = 0, (bool) $crop = false ); 

Parameters (3)

0. $width — Optional. (int)
Image width in pixels.
1. $height — Optional. (int)
Image height in pixels.
2. $crop — Optional. (bool) => false
Whether to crop images to specified width and height or resize. An array can specify positioning of the crop area. Default false.

Usage

  1. if ( !function_exists( 'set_post_thumbnail_size' ) ) { 
  2. require_once ABSPATH . WPINC . '/media.php'; 
  3.  
  4. // Image width in pixels. 
  5. $width = -1; 
  6.  
  7. // Image height in pixels. 
  8. $height = -1; 
  9.  
  10. // Optional. Whether to crop images to specified width and height or resize. 
  11. // An array can specify positioning of the crop area. Default false. 
  12. $crop = false; 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = set_post_thumbnail_size($width, $height, $crop); 
  16.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/media.php  
  1. function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) { 
  2. add_image_size( 'post-thumbnail', $width, $height, $crop );