WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#43070 new defect (bug)

srcset attribute can be overridden but not prevented

Reported by: desrosj Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.4
Component: Media Keywords: needs-patch
Focuses: Cc:

Description

In wp_get_attachment_image(), a srcset attribute can be passed to the fourth parameter to override the attribute's contents. There is no way to prevent this attribute from showing, though. An empty srcset attribute throws a validation error.

Change History (1)

#1 @desrosj
5 months ago

Of note, the srcset can be removed with the wp_get_attachment_image_attributes filter. But, that is not ideal.

My use case: I am generating a <picture> element fallback <img /> that can't have srcset or sizes attributes.

Note: See TracTickets for help on using tickets.