apply_filters( 'wp_get_attachment_link', string $link_html, int|WP_Post $post, string|int[] $size, bool $permalink, bool $icon, string|false $text, array|string $attr )
- Since
- 2.7.0, 5.1.0
Filters a retrieved attachment page link.
Compatibility
- WordPress
- since 5.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$link_htmlstring- The page link HTML output.
$postint|WP_Post- Post ID or object. Can be 0 for the current global post.
$sizestring|int[]- Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
$permalinkbool- Whether to add permalink to image. Default false.
$iconbool- Whether to include an icon.
$textstring|false- If string, will be link text.
$attrarray|string- Array or string of attributes.
Where this hook fires · 1
wp-includes/post-template.php:1712wp_get_attachment_link()
Source code
* an array of width and height values in pixels (in that order). * @param bool $permalink Whether to add permalink to image. Default false. * @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 apply_filters( 'wp_get_attachment_link', $link_html, $post, $size, $permalink, $icon, $text, $attr );} /** * Wraps attachment in paragraph tag before content. * * @since 2.0.0Changelog
Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
5.1.0
Added the
$attr parameter.from the docblock2.7.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.