wp_calculate_image_sizes

SummerySummery

Creates a ‘sizes’ attribute value for an image.

Syntax

wp_calculate_image_sizes( array|string $size, string $image_src = null, array $image_meta = null, int $attachment_id )

ParametersParameters

$size

(array|string) (Required) Image size to retrieve. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default 'medium'.

$image_src

(string) (Optional) The URL to the image file.

Default value: null

$image_meta

(array) (Optional) The image meta data as returned by 'wp_get_attachment_metadata()'.

Default value: null

$attachment_id

(int) (Optional) Image attachment ID. Either $image_meta or $attachment_id is needed when using the image size name as argument for $size. Default 0.

ReturnReturn

(string|bool) A valid source size value for use in a 'sizes' attribute or false.

SourceSource

File: wp-includes/media.php


			

ChangelogChangelog

Changelog
Version Description
4.4.0 Introduced.
Scroll to Top