wp_image_add_srcset_and_sizes

SummerySummery

Adds ‘srcset’ and ‘sizes’ attributes to an existing ‘img’ element.

Syntax

wp_image_add_srcset_and_sizes( string $image, array $image_meta, int $attachment_id )

ParametersParameters

$image

(string) (Required) An HTML 'img' element to be filtered.

$image_meta

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

$attachment_id

(int) (Required) Image attachment ID.

ReturnReturn

(string) Converted 'img' element with 'srcset' and 'sizes' attributes added.

SourceSource

File: wp-includes/media.php


			

ChangelogChangelog

Changelog
Version Description
4.4.0 Introduced.

See alsoSee also

Scroll to Top