Index: src/wp-admin/includes/image.php
===================================================================
--- src/wp-admin/includes/image.php	(revision 42156)
+++ src/wp-admin/includes/image.php	(working copy)
@@ -250,30 +250,36 @@
 		// Only load PDFs in an image editor if we're processing sizes.
 		if ( ! empty( $sizes ) ) {
 			$editor = wp_get_image_editor( $file );
+			if ( is_wp_error( $editor ) ) {
+				// No support for this type of file.
+				return $editor;
+			}
 
-			if ( ! is_wp_error( $editor ) ) { // No support for this type of file
-				/*
-				 * PDFs may have the same file filename as JPEGs.
-				 * Ensure the PDF preview image does not overwrite any JPEG images that already exist.
-				 */
-				$dirname = dirname( $file ) . '/';
-				$ext = '.' . pathinfo( $file, PATHINFO_EXTENSION );
-				$preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' );
+			/*
+			 * PDFs may have the same file filename as JPEGs.
+			 * Ensure the PDF preview image does not overwrite any JPEG images that already exist.
+			 */
+			$dirname = dirname( $file ) . '/';
+			$ext = '.' . pathinfo( $file, PATHINFO_EXTENSION );
+			$preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' );
 
-				$uploaded = $editor->save( $preview_file, 'image/jpeg' );
-				unset( $editor );
+			$uploaded = $editor->save( $preview_file, 'image/jpeg' );
+			unset( $editor );
 
-				// Resize based on the full size image, rather than the source.
-				if ( ! is_wp_error( $uploaded ) ) {
-					$editor = wp_get_image_editor( $uploaded['path'] );
-					unset( $uploaded['path'] );
+			if ( is_wp_error( $uploaded ) ) {
+				return $uploaded;
+			}
 
-					if ( ! is_wp_error( $editor ) ) {
-						$metadata['sizes'] = $editor->multi_resize( $sizes );
-						$metadata['sizes']['full'] = $uploaded;
-					}
-				}
+			// Resize based on the full size image, rather than the source.
+			$editor = wp_get_image_editor( $uploaded['path'] );
+			unset( $uploaded['path'] );
+
+			if ( is_wp_error( $editor ) ) {
+				return $editor;
 			}
+
+			$metadata['sizes'] = $editor->multi_resize( $sizes );
+			$metadata['sizes']['full'] = $uploaded;
 		}
 	}
 
