Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/image resize dimensions


Retrieve calculated resized dimensions for use in imagecopyresampled().

Calculate dimensions and coordinates for a resized image that fits within a specified width and height. If $crop is true, the largest matching central portion of the image will be cropped out and resized to the required size.


<?php image_resize_dimensions$orig_w$orig_h$dest_w$dest_h$crop ); ?>


(int) (required) Original width.
Default: None
(int) (required) Original height.
Default: None
(int) (required) New width.
Default: None
(int) (required) New height.
Default: None
(boolean) (optional) Optional, default is false. Whether to crop image or resize.
Default: false

Return Values

False, on failure. Returned array matches parameters for imagecopyresampled() PHP function.

Change Log

Since: 2.5

Source File

image_resize_dimensions() is located in wp-includes/media.php