Core Function
View Source on Trac ↗ wp_calculate_image_sizes()
wp_calculate_image_sizes(
mixed $size,
mixed $image_src = null,
mixed $image_meta = null,
mixed $attachment_id = 0
) Creates a 'sizes' attribute value for an image.
Parameters 4 required
| Name / Type | Description |
|---|---|
| mixed | (string | int[]) $size Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Required |
| (string | | null) $image_src Optional. The URL to the image file. Default null. Required |
| mixed | (array | null) $image_meta Optional. The image meta data as returned by 'wp_get_attachment_metadata()'. Default null. Required |
| int | $attachment_id Optional. Image attachment ID. Either `$image_meta` or `$attachment_id` is needed when using the image size name as argument for `$size`. Default 0. Required |
Return Value
((string)
| false) A valid source size value for use in a 'sizes' attribute or false.
Function Information
Since Version
4.4.0
Source File
wp-includes/media.php
Advertisement