Make WordPress Core

Opened 6 years ago

Last modified 5 years ago

#43070 new defect (bug)

srcset attribute can be overridden but not prevented

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


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 (2)

#1 @desrosj
6 years 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.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

5 years ago

Note: See TracTickets for help on using tickets.