image_resize_dimensions
image_resize_dimensions ( $orig_w, $orig_h, $dest_w, $dest_h, $crop = false )
Parameters:- (int) orig_w Original width in pixels.
- (int) orig_h Original height in pixels.
- (int) dest_w New width in pixels.
- (int) dest_h New height in pixels.
- (bool|array) crop Optional. Whether to crop image to specified width and height or resize. An array can specify positioning of the crop area. Default false.
Returns:- (array|false) Returned array matches parameters for `imagecopyresampled()`. False on failure.
Defined at: - Introduced in WordPress: 2.5.0
- Deprecated in WordPress: —
Description
Retrieves calculated resize dimensions for use in WP_Image_Editor.Calculates dimensions and coordinates for a resized image that fits
within a specified width and height.
Cropping behavior is dependent on the value of $crop:
1. If false (default), images will not be cropped.
2. If an array in the form of array( x_crop_position, y_crop_position ):
- x_crop_position accepts 'left' 'center', or 'right'.
- y_crop_position accepts 'top', 'center', or 'bottom'.
Images will be cropped to the specified dimensions within the defined crop area.
3. If true, images will be cropped to the specified dimensions using center positions.