A WordPress-centric search engine for devs and theme authors

wp_img_tag_add_srcset_and_sizes_attr ›

apply_filters( 'wp_img_tag_add_srcset_and_sizes_attr', true, $image, $context, $attachment_id )
Parameters: (4)
  • (bool) $value The filtered value, defaults to `true`.
    Required: Yes
  • (string) $image The HTML `img` tag where the attribute should be added.
    Required: Yes
  • (string) $context Additional context about how the function was called or where the img tag is.
    Required: Yes
  • (int) $attachment_id The image attachment ID.
    Required: Yes
Defined at:

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

Returning anything else than true will not add the attributes.


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