WPDev.one
Core Function
View Source on Trac ↗

wp_get_attachment_image_srcset()

wp_get_attachment_image_srcset( mixed $attachment_id, mixed $size = 'medium', mixed $image_meta = null )

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

Parameters 3 required

Name / Type Description
$attachment_id
int

Image attachment ID.

Required
mixed

(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'.

Required
mixed

(array | null) $image_meta Optional. The image meta data as returned by 'wp_get_attachment_metadata()'. Default null.

Required

Return Value

((string)
| false) A 'srcset' value string or false.

Function Information

Since Version
4.4.0
Source File
wp-includes/media.php
Advertisement