wp_get_attachment_link filter-hookWP 2.7.0

Filters a retrieved attachment page link.

Usage

add_filter( 'wp_get_attachment_link', 'wp_kama_get_attachment_link_filter', 10, 7 );

/**
 * Function for `wp_get_attachment_link` filter-hook.
 * 
 * @param string       $link_html The page link HTML output.
 * @param int|WP_Post  $id        Post ID or object. Can be 0 for the current global post.
 * @param string|int[] $size      Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
 * @param bool         $permalink Whether to add permalink to image.
 * @param bool         $icon      Whether to include an icon.
 * @param string|false $text      If string, will be link text.
 * @param array|string $attr      Array or string of attributes.
 *
 * @return string
 */
function wp_kama_get_attachment_link_filter( $link_html, $id, $size, $permalink, $icon, $text, $attr ){

	// filter...
	return $link_html;
}
$link_html(string)
The page link HTML output.
$id(int|WP_Post)
Post ID or object. Can be 0 for the current global post.
$size(string|int[])
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
$permalink(true|false)
Whether to add permalink to image.
Default: false
$icon(true|false)
Whether to include an icon.
$text(string|false)
If string, will be link text.
$attr(array|string)
Array or string of attributes.

Changelog

Since 2.7.0 Introduced.
Since 5.1.0 Added the $attr parameter.

Where the hook is called

wp_get_attachment_link()
wp_get_attachment_link
wp-includes/post-template.php 1659
return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text, $attr );

Where the hook is used in WordPress

Usage not found.