diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index fd4d0a1205..b0781b572d 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -190,10 +190,11 @@ class WP_Image_Editor_GD extends WP_Image_Editor { $resized = $this->_save( $image ); imagedestroy( $image ); - unset( $resized['path'] ); - if ( ! is_wp_error( $resized ) && $resized ) + if ( ! is_wp_error( $resized ) && $resized ) { + unset( $resized['path'] ); $metadata[$size] = $resized; + } } $this->size = $orig_size; diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index 179cadabb4..21e4e0cac3 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -268,10 +268,11 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { $this->image->clear(); $this->image->destroy(); $this->image = null; - unset( $resized['path'] ); - if ( ! is_wp_error( $resized ) && $resized ) + if ( ! is_wp_error( $resized ) && $resized ) { + unset( $resized['path'] ); $metadata[$size] = $resized; + } } $this->size = $orig_size;