Definition:
function update_attached_file( $attachment_id, $file ) {}
Update attachment file path based on attachment ID.
Used to update the file path of the attachment, which uses post meta name ‘_wp_attached_file’ to store the path of the attachment.
Parameters
- int $attachment_id: Attachment ID
- string $file: File path for the attachment
Return values
returns:False on failure, true on success.
Defined filters
- update_attached_file
apply_filters( 'update_attached_file', $file, $attachment_id )
Source code
function update_attached_file( $attachment_id, $file ) { if ( !get_post( $attachment_id ) ) return false; $file = apply_filters( 'update_attached_file', $file, $attachment_id ); $file = _wp_relative_upload_path($file); return update_post_meta( $attachment_id, '_wp_attached_file', $file ); }
3153
No comments yet... Be the first to leave a reply!