diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php index f390b5e418..0b0692662b 100644 --- a/wp-admin/includes/image-edit.php +++ b/wp-admin/includes/image-edit.php @@ -568,7 +568,7 @@ function wp_save_image( $post_id ) { $post = get_post( $post_id ); $img = WP_Image_Editor::get_instance( _load_image_to_edit_path( $post_id, 'full' ) ); - if ( !$img ) { + if ( is_wp_error( $img ) ) { $return->error = esc_js( __('Unable to create new image.') ); return $return; } diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 2a5123e54d..6ea4edecea 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -33,8 +33,10 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_ } $editor = WP_Image_Editor::get_instance( $src_file ); - $src = $editor->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs ); + if ( is_wp_error( $editor ) ) + return $editor; + $src = $editor->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs ); if ( is_wp_error( $src ) ) return $src; @@ -94,7 +96,9 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes ); $editor = WP_Image_Editor::get_instance( $file ); - $metadata['sizes'] = $editor->multi_resize( $sizes ); + + if ( ! is_wp_error( $editor ) ) + $metadata['sizes'] = $editor->multi_resize( $sizes ); // fetch additional metadata from exif/iptc $image_meta = wp_read_image_metadata( $file ); diff --git a/wp-includes/media.php b/wp-includes/media.php index 992df2bc9a..156d6ca6c2 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -383,7 +383,7 @@ function image_make_intermediate_size( $file, $width, $height, $crop = false ) { if ( $width || $height ) { $editor = WP_Image_Editor::get_instance( $file ); - if ( is_wp_error( $editor->resize( $width, $height, $crop ) ) ); + if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ); return false; $resized_file = $editor->save();