image_downsize

SummerySummery

Scale an image to fit a particular size (such as ‘thumb’ or ‘medium’).

Syntax

image_downsize( int $id, string|int[] $size = 'medium' )

DescriptionDescription

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 normally returned from the function.

ParametersParameters

$id

(int) (Required) Attachment ID for image.

$size

(string|int[]) (Optional) Image size to scale to. Accepts any valid image size name, or an array of width and height values in pixels (in that order).

Default value: 'medium'

ReturnReturn

(array|false) Array of image data, or boolean false if no image is available.

  • (string) Image source URL.
  • '1'
    (int) Image width in pixels.
  • '2'
    (int) Image height in pixels.
  • '3'
    (bool) Whether the image is a resized image.

SourceSource

File: wp-includes/media.php


			

ChangelogChangelog

Changelog
Version Description
2.5.0 Introduced.
Scroll to Top