Opened 12 years ago
Last modified 6 years ago
#22075 new enhancement
Allow custom attributes to be set in `wp_get_attachment_link`
Reported by: | webord | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4 |
Component: | Media | Keywords: | dev-feedback has-patch needs-refresh needs-unit-tests |
Focuses: | Cc: |
Description
I answered a question not so long ago on WordPress StackExchange.
There I saw the need on a filter for wp_get_attachment_link()
to allow the developer to add or remove attributes to the HTML without having to use a regex on it or creating the a
tag again.
So I've done this small patch with changes to apply this enhancement to the function.
Attachments (3)
Change History (12)
#4
@
11 years ago
- Keywords has-patch removed
Sure, sounds valid.
I'm not a fan of daisy chaining more parameters onto the function's signature. Perhaps we could consider moving over to an array hash while supporting backwards compatibility a la BuddyPress?
#5
@
11 years ago
- Summary changed from Improving `wp_get_attachment_link` to Allow custom attributes to be set in `wp_get_attachment_link`
#6
@
11 years ago
attachment:22075.3.diff changes the function to take an array hash as the only parameter, with backwards compatibility inspired by BuddyPress.
#7
follow-up:
↓ 8
@
11 years ago
After thinking about this for a bit, I'm not sure we want to tack on more options to this function.
The question from WPSE asks "how do I customize the output of the gallery shortcode to look nothing like what it does out of the box," and in all honesty if you want to do that, you should probably do it via the post_gallery
shortcode.
To the topic at hand, if you want to add custom attributes to the anchor tag in wp_get_attachment_link()
, you should probably use the wp_get_attachment_link
filter and instead of regexing just rebuild the string however you see fit.
#8
in reply to:
↑ 7
@
11 years ago
Replying to ericlewis:
To the topic at hand, if you want to add custom attributes to the anchor tag in
wp_get_attachment_link()
, you should probably use thewp_get_attachment_link
filter and instead of regexing just rebuild the string however you see fit.
I tend to agree. It's a short function, there's not much to rebuild.
post-template.php