Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#41574 new enhancement

Add filter: wp_get_attachment_link_attributes

Reported by: NathanAtmoz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch 2nd-opinion
Focuses: Cc:


Similar to wp_get_attachment_image_attributes, it would be nice to be able to filter the link attributes when getting the attachment link.

Attachments (2)

41574.1.diff (1.5 KB) - added by NathanAtmoz 4 years ago.
41574.2.diff (1.5 KB) - added by NathanAtmoz 4 years ago.
add missing >

Download all attachments as: .zip

Change History (5)

4 years ago

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Media
  • Keywords has-patch added

4 years ago

add missing >

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

3 years ago

#3 @aaroncampbell
3 years ago

  • Keywords 2nd-opinion added

Overall I like the idea here. Being able to add classes and such to the <a> element would be helpful, and with the download attribute gaining browser support, I can see that being useful too.

I do have a small concern here though: The $attr that’s passed into wp_get_attachment_link() currently just passes through to wp_get_attachment_image(). That’s going to be really weird once the links support attributes themselves.

Does anyone have any thoughts on what can be done there to keep back compat and ease confusion? Maybe rename that parameter? Do we need to add yet ANOTHER parameter there for consistency?

Note: See TracTickets for help on using tickets.