add_image_size
Register a new image size.
Description
Cropping behavior for the image size is dependent on the value of $crop
: 1. If false (default), images will be scaled, not cropped. 2. If an array in the form of array( x_crop_position, y_crop_position ): 3. If true, images will be cropped to the specified dimensions using center positions.
Parameters (4)
- 0. $name (string)
- Image size identifier.
- 1. $width — Optional. (int)
- Image width in pixels.
- 2. $height — Optional. (int)
- Image height in pixels.
- 3. $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
if ( !function_exists( 'add_image_size' ) ) { require_once ABSPATH . WPINC . '/media.php'; } // Image size identifier. $name = ''; // Image width in pixels. $width = -1; // Image height in pixels. $height = -1; // Optional. Whether to crop images to specified width and height or resize. // An array can specify positioning of the crop area. Default false. $crop = false; // NOTICE! Understand what this does before running. $result = add_image_size($name, $width, $height, $crop);
Defined (1)
The function is defined in the following location(s).