
WordPress Cookies和PHP会话——你需要知道的一切
_wp_image_meta_replace_original ( $saved_data, $original_file, $image_meta, $attachment_id )
_wp_image_meta_replace_original: 这个函数用一个新图片的元数据来替换原始图片的元数据。它通常用于通过上传相同文件名的新图片来替换一个图片。
当原始图像被编辑时,更新附件文件和图像元数据。
function _wp_image_meta_replace_original( $saved_data, $original_file, $image_meta, $attachment_id ) { $new_file = $saved_data['path']; // Update the attached file meta. update_attached_file( $attachment_id, $new_file ); // Width and height of the new image. $image_meta['width'] = $saved_data['width']; $image_meta['height'] = $saved_data['height']; // Make the file path relative to the upload dir. $image_meta['file'] = _wp_relative_upload_path( $new_file ); // Add image file size. $image_meta['filesize'] = wp_filesize( $new_file ); // Store the original image file name in image_meta. $image_meta['original_image'] = wp_basename( $original_file ); return $image_meta; }