diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php index 5417eac45e..7f9ebf7f9f 100644 --- a/wp-admin/includes/image-edit.php +++ b/wp-admin/includes/image-edit.php @@ -826,9 +826,10 @@ function wp_restore_image( $post_id ) { } } elseif ( isset( $meta['width'], $meta['height'] ) ) { $backup_sizes[ "full-$suffix" ] = array( - 'width' => $meta['width'], - 'height' => $meta['height'], - 'file' => $parts['basename'], + 'width' => $meta['width'], + 'height' => $meta['height'], + 'filesize' => $meta['filesize'], + 'file' => $parts['basename'], ); } } @@ -839,6 +840,14 @@ function wp_restore_image( $post_id ) { $meta['file'] = _wp_relative_upload_path( $restored_file ); $meta['width'] = $data['width']; $meta['height'] = $data['height']; + if ( isset( $data['filesize'] ) ) { + /* + * Restore the original filesize if it was backed up. + * + * See https://core.trac.wordpress.org/ticket/59684. + */ + $meta['filesize'] = $data['filesize']; + } } foreach ( $default_sizes as $default_size ) { @@ -997,8 +1006,9 @@ function wp_save_image( $post_id ) { } } + $saved_image = wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id ); // Save the full-size file, also needed to create sub-sizes. - if ( ! wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id ) ) { + if ( ! $saved_image ) { $return->error = esc_js( __( 'Unable to save the image.' ) ); return $return; } @@ -1018,9 +1028,10 @@ function wp_save_image( $post_id ) { if ( $tag ) { $backup_sizes[ $tag ] = array( - 'width' => $meta['width'], - 'height' => $meta['height'], - 'file' => $basename, + 'width' => $meta['width'], + 'height' => $meta['height'], + 'filesize' => $meta['filesize'], + 'file' => $basename, ); } @@ -1028,9 +1039,10 @@ function wp_save_image( $post_id ) { $meta['file'] = _wp_relative_upload_path( $new_path ); - $size = $img->get_size(); - $meta['width'] = $size['width']; - $meta['height'] = $size['height']; + $size = $img->get_size(); + $meta['width'] = $size['width']; + $meta['height'] = $size['height']; + $meta['filesize'] = $saved_image['filesize']; if ( $success && ( 'nothumb' === $target || 'all' === $target ) ) { $sizes = get_intermediate_image_sizes(); diff --git a/wp-includes/version.php b/wp-includes/version.php index 28a65b5852..49df52e28e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-beta2-59201'; +$wp_version = '6.7-beta2-59202'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.