image_downsize( int $id, array|string $size = 'medium' )
Scale an image to fit a particular size (such as ‘thumb’ or ‘medium’).
Description
Array with image url, width, height, and whether is intermediate size, in that order is returned on success is returned. $is_intermediate is true if $url is a resized image, false if it is the original.
The URL might be the original image, or it might be a resized version. This function won’t create a new resized copy, it will just return an already resized one if it exists.
A plugin may use the ‘image_downsize’ filter to hook into and offer image resizing services for images. The hook must return an array with the same elements that are returned in the function. The first element being the URL to the new image that was resized.
Parameters
- $id
-
(Required) Attachment ID for image.
- $size
-
(Optional) Image size to scale to. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default 'medium'.
Default value: 'medium'
Return
(false|array) Array containing the image URL, width, height, and boolean for whether the image is an intermediate size. False on failure.
Source
File: wp-includes/media.php
Changelog
Version | Description |
---|---|
WP-2.5.0 | Introduced. |