wp_get_attachment_url
Filters the attachment URL.
Usage
add_filter( 'wp_get_attachment_url', 'wp_kama_get_attachment_url_filter', 10, 2 );
/**
* Function for `wp_get_attachment_url` filter-hook.
*
* @param string $url URL for the given attachment.
* @param int $attachment_id Attachment post ID.
*
* @return string
*/
function wp_kama_get_attachment_url_filter( $url, $attachment_id ){
// filter...
return $url;
}
- $url(string)
- URL for the given attachment.
- $attachment_id(int)
- Attachment post ID.
Changelog
| Since 2.1.0 | Introduced. |
Where the hook is called
wp_get_attachment_url
wp-includes/post.php 7027
$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );