From 4c81af47fa3412568f8a487d79bf785641033e0f Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Wed, 1 Feb 2023 20:29:56 +0000 Subject: [PATCH] Media: Remove meta data after restoring w/IMAGE_EDIT_OVERWRITE. When IMAGE_EDIT_OVERWRITE is defined as true the meta field `_wp_attachment_backup_sizes` is deleted after an image is restored. Props mitogh, jeawhanlee, robinwpdeveloper, iapial. Fixes #55150. git-svn-id: https://develop.svn.wordpress.org/trunk@55180 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/image-edit.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index 746c0bafbd..281ce03c0f 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -810,6 +810,9 @@ function wp_restore_image( $post_id ) { $msg->error = __( 'Image metadata is inconsistent.' ); } else { $msg->msg = __( 'Image restored successfully.' ); + if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) { + delete_post_meta( $post_id, '_wp_attachment_backup_sizes' ); + } } return $msg;