Retrieves the value for an image attachment’s ‘srcset’ attribute.
Description
See also
Parameters
$attachment_id
intrequired- Image attachment ID.
$size
string|int[]optional- Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default
'medium'
.Default:
'medium'
$image_meta
array|nulloptional- The image meta data as returned by ‘wp_get_attachment_metadata() ‘.
Default:
null
Source
absint( $image_meta['sizes'][ $size_name ]['height'] ),
);
}
return false;
}
/**
* Retrieves the value for an image attachment's 'srcset' attribute.
*
* @since 4.4.0
*
* @see wp_calculate_image_srcset()
*
* @param int $attachment_id Image attachment ID.
* @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array of
* width and height values in pixels (in that order). Default 'medium'.
* @param array|null $image_meta Optional. The image meta data as returned by 'wp_get_attachment_metadata()'.
* Default null.
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
Using
$size
as an array of width and height dimensions: