Function: wp_get_attachment_image_sizes

wp_get_attachment_image_sizes( integer $attachment_id, array | string $size, array $image_meta )

Retrieves the value for an image attachment's 'sizes' attribute.


Name Type(s) Default Value Description
$attachment_id integer

Image attachment ID.

$size array | string 'medium'

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

$image_meta array null

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


string | boolean

A valid source size value for use in a 'sizes' attribute or false.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.