+ $sizes = array();
+
+ foreach ( $fallback_sizes as $s ) {
+ $sizes[ $s ]['width'] = get_option( "{$s}_size_w" );
+ $sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
+
+ // Force thumbnails to be soft crops.
+ if ( ! 'thumbnail' === $s ) {
+ $sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
+ }
+ }
+
+ // 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
+ $uploaded = $editor->save( $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( $editor ) ) {
+ $metadata['sizes'] = $editor->multi_resize( $sizes );
+ $metadata['sizes']['full'] = $uploaded;
+ }
+ }
+ }
+ }
+ }
+
+ // Remove the blob of binary data from the array.
+ if ( $metadata ) {