get_attached_file
Filters the attached file based on the given ID.
Usage
add_filter( 'get_attached_file', 'wp_kama_get_attached_file_filter', 10, 2 ); /** * Function for `get_attached_file` filter-hook. * * @param string|false $file The file path to where the attached file should be, false otherwise. * @param int $attachment_id Attachment ID. * * @return string|false */ function wp_kama_get_attached_file_filter( $file, $attachment_id ){ // filter... return $file; }
- $file(string|false)
- The file path to where the attached file should be, false otherwise.
- $attachment_id(int)
- Attachment ID.
Changelog
Since 2.1.0 | Introduced. |
Where the hook is called
get_attached_file
wp-includes/post.php 848
return apply_filters( 'get_attached_file', $file, $attachment_id );