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.
Signature
update_attached_file( $attachment_id, $file )
- attachment_id
- (int) Attachment ID
- file
- (string) File path for the attachment
Return
(boolean) False on failure, true on success.
Source
function update_attached_file( $attachment_id, $file ) {
if ( !get_post( $attachment_id ) )
return false;
$file = apply_filters( 'update_attached_file', $file, $attachment_id );
if ( $file = _wp_relative_upload_path( $file ) )
return update_post_meta( $attachment_id, '_wp_attached_file', $file );
else
return delete_post_meta( $attachment_id, '_wp_attached_file' );
}
WP Trac GitHub Bitbucket
Link here
-
URL
http://queryposts.com/function/update_attached_file/ -
HTML
<a href='http://queryposts.com/function/update_attached_file/'>update_attached_file()</a> -
Markdown
[update_attached_file()](http://queryposts.com/function/update_attached_file/) -
BBCode
[url=http://queryposts.com/function/update_attached_file/]update_attached_file()[/url]