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

Function Reference/image get intermediate size


Retrieve the image's intermediate size (resized) path, width, and height.

The $size parameter can be an array with the width and height respectively. If the size matches the 'sizes' metadata array for width and height, then it will be used. If there is no direct match, then the nearest image size larger than the specified size will be used. If nothing is found, then the function will break out and return false.

The metadata 'sizes' is used for compatible sizes that can be used for the parameter $size value.

The url path will be given, when the $size parameter is a string.

If you are passing an array for the $size, you should consider using add_image_size() so that a cropped version is generated. It's much more efficient than having to find the closest-sized image and then having the browser scale down the image.


<?php image_get_intermediate_size$attachment_id$size ); ?>


(int) (required) Attachment ID for image.
Default: None
(array|string) (optional) Optional, default is 'thumbnail'. Size of image, either array or string.
Default: thumbnail

Return Values

False on failure or array of file path, width, and height on success.

Change Log

Since: 2.5

Source File

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