WordPress filter hook · part of WordPress core
wp_get_attachment_link
A WordPress core filter that 3 plugins also fire themselves, running on 5,010+ sites between them.
How to use wp_get_attachment_link
It's a filter: your callback receives the value and 5 more arguments, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'wp_get_attachment_link', function( $gallery_attachment_link_html, $mid, $size, $href, $arg5, $arg6 ) {
// Change $gallery_attachment_link_html here.
return $gallery_attachment_link_html;
}, 10, 6 );Argument names come from Responsive Gallery Grid's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
3 plugins that fire wp_get_attachment_link
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
Responsive Gallery Grid4,000+ installs
apply_filters( 'wp_get_attachment_link', $gallery_attachment_link_html, $mid, $size, $href, false, false )gallery-shortcode.php:458 -
Image Carousel1,000+ installs
apply_filters( 'wp_get_attachment_link', "<a $link_class $link_target href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text )inc/functions/icp-functions.php:479 -
Fast Gallery Lite10+ installs
apply_filters( 'wp_get_attachment_link', "<div class='fg_zoom'>$link_text<a href='$url' title=\"$attachment_caption\" data-rel='prettyPhoto[album]' class='fg_magnificPopup'><span class='fg-zoom-icon icon-plus'></span><span style='display:none'>$link_text</span></a></div>", $id, $size, $permalink, $icon, $text )functions.php:314
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.