attachment_link
Filters the permalink for an attachment.
Usage
add_filter( 'attachment_link', 'wp_kama_attachment_link_filter', 10, 2 ); /** * Function for `attachment_link` filter-hook. * * @param string $link The attachment's permalink. * @param int $post_id Attachment ID. * * @return string */ function wp_kama_attachment_link_filter( $link, $post_id ){ // filter... return $link; }
- $link(string)
- The attachment's permalink.
- $post_id(int)
- Attachment ID.
Changelog
Since 2.0.0 | Introduced. |
Since 5.6.0 | Providing an empty string will now disable the view attachment page link on the media modal. |
Where the hook is called
attachment_link
wp-includes/link-template.php 534
return apply_filters( 'attachment_link', $link, $post->ID );