Upload: Ensure the new image meta is always saved before starting post-processing of an uploaded image, even if there was an error while scaling or rotating it.

See #48472.

git-svn-id: https://develop.svn.wordpress.org/trunk@46651 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2019-11-04 17:05:53 +00:00
parent 20165c2ffb
commit 9ed5e8c9f7

View File

@ -287,11 +287,6 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
if ( true === $rotated && ! empty( $image_meta['image_meta']['orientation'] ) ) {
$image_meta['image_meta']['orientation'] = 1;
}
// Initial save of the new metadata when the original image was scaled.
// At this point the file was uploaded and moved to the uploads directory
// but the image sub-sizes haven't been created yet and the `sizes` array is empty.
wp_update_attachment_metadata( $attachment_id, $image_meta );
} else {
// TODO: log errors.
}
@ -322,18 +317,17 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
if ( ! empty( $image_meta['image_meta']['orientation'] ) ) {
$image_meta['image_meta']['orientation'] = 1;
}
// Initial save of the new metadata when the original image was rotated.
wp_update_attachment_metadata( $attachment_id, $image_meta );
} else {
// TODO: log errors.
}
}
} else {
// Initial save of the new metadata when the image was not scaled or rotated.
wp_update_attachment_metadata( $attachment_id, $image_meta );
}
// Initial save of the new metadata.
// At this point the file was uploaded and moved to the uploads directory
// but the image sub-sizes haven't been created yet and the `sizes` array is empty.
wp_update_attachment_metadata( $attachment_id, $image_meta );
$new_sizes = wp_get_registered_image_subsizes();
/**