wp_img_tag_add_srcset_and_sizes_attr WordPress Filter Hook

This hook allows you to add additional image sizes to the srcset attribute of an image. This can be useful for responsive images or for providing high-resolution images for Retina displays.

apply_filters( 'wp_img_tag_add_srcset_and_sizes_attr', bool $value, string $image, string $context, int $attachment_id ) #

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.


Top ↑

Parameters

$value

(bool)The filtered value, defaults to true.

$image

(string)The HTML img tag where the attribute should be added.

$context

(string)Additional context about how the function was called or where the img tag is.

$attachment_id

(int)The image attachment ID.


Top ↑

Source

File: wp-includes/media.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More