image_resize_dimensions ( $orig_w, $orig_h, $dest_w, $dest_h, $crop = false )

  • (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.
  • (array|false) Returned array matches parameters for `imagecopyresampled()`. False on failure.
Defined at:


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.

Related Functions

wp_image_src_get_dimensions, image_resize, wp_shrink_dimensions, image_size_input_fields, wp_constrain_dimensions

Top Google Results

User discussions

wpseek mobile