You appear to be a bot. Output may be restricted
Description
Create the attachment metadataIf this is a replacement file then we need to store the new file name in _wp_attached_file as wp_update_attachment_metadata() doesn't do it for us.
Usage
oik_clone_update_attachment_metadata( $target_id, $media_file );
Parameters
- $target_id
- ( ID ) required – the target attachment
- $media_file
- ( string ) required – the full file name of the attached file
Returns
voidSource
File name: oik-clone/admin/oik-clone-media.phpLines:
1 to 10 of 10
function oik_clone_update_attachment_metadata( $target_id, $media_file ) { require_once ABSPATH . 'wp-admin/includes/image.php'; $metadata = wp_generate_attachment_metadata( $target_id, $media_file ); bw_trace2( $metadata, "attachment_metadata" ); wp_update_attachment_metadata( $target_id, $metadata ); $attached_file = bw_array_get( $metadata, 'file', null ); if ( $attached_file ) { update_post_meta( $target_id, "_wp_attached_file" , $attached_file ); } }View on GitHub