apply_filters( ‘wp_img_tag_add_srcset_and_sizes_attr’, bool $value, string $image, string $context, int $attachment_id )

In this article

Filters whether to add the srcset and sizes HTML attributes to the img tag. Default true.

Description

Returning anything else than true will not add the attributes.

Parameters

$valuebool
The filtered value, defaults to true.
$imagestring
The HTML img tag where the attribute should be added.
$contextstring
Additional context about how the function was called or where the img tag is.
$attachment_idint
The image attachment ID.

Source

$add = apply_filters( 'wp_img_tag_add_srcset_and_sizes_attr', true, $image, $context, $attachment_id );

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.