diff --git src/wp-admin/includes/image.php src/wp-admin/includes/image.php
index 87b8191..d9df4c8 100644
|
|
|
function wp_generate_attachment_metadata( $attachment_id, $file ) { |
| 205 | 205 | } |
| 206 | 206 | // Try to create image thumbnails for PDFs |
| 207 | 207 | else if ( 'application/pdf' === $mime_type ) { |
| 208 | | $editor = wp_get_image_editor( $file ); |
| 209 | | |
| 210 | 208 | $fallback_sizes = array( |
| 211 | 209 | 'thumbnail', |
| 212 | 210 | 'medium', |
| 213 | 211 | 'large', |
| 214 | 212 | ); |
| 215 | 213 | |
| | 214 | /** |
| | 215 | * Filters the image sizes generated for non-image mime types. |
| | 216 | * |
| | 217 | * @since 4.7.0 |
| | 218 | * |
| | 219 | * @param array $fallback_sizes An array of image size names. |
| | 220 | */ |
| | 221 | $fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata ); |
| | 222 | |
| 216 | 223 | $sizes = array(); |
| 217 | 224 | |
| 218 | 225 | foreach ( $fallback_sizes as $s ) { |
| … |
… |
function wp_generate_attachment_metadata( $attachment_id, $file ) { |
| 225 | 232 | } |
| 226 | 233 | } |
| 227 | 234 | |
| 228 | | if ( ! is_wp_error( $editor ) ) { // No support for this type of file |
| 229 | | $uploaded = $editor->save( $file, 'image/jpeg' ); |
| 230 | | unset( $editor ); |
| | 235 | // Only load PDFs in an image editor if we're processing sizes. |
| | 236 | if ( ! empty( $sizes ) ) { |
| | 237 | $editor = wp_get_image_editor( $file ); |
| | 238 | |
| | 239 | if ( ! is_wp_error( $editor ) ) { // No support for this type of file |
| | 240 | $uploaded = $editor->save( $file, 'image/jpeg' ); |
| | 241 | unset( $editor ); |
| 231 | 242 | |
| 232 | | // Resize based on the full size image, rather than the source. |
| 233 | | if ( ! is_wp_error( $uploaded ) ) { |
| 234 | | $editor = wp_get_image_editor( $uploaded['path'] ); |
| 235 | | unset( $uploaded['path'] ); |
| | 243 | // Resize based on the full size image, rather than the source. |
| | 244 | if ( ! is_wp_error( $uploaded ) ) { |
| | 245 | $editor = wp_get_image_editor( $uploaded['path'] ); |
| | 246 | unset( $uploaded['path'] ); |
| 236 | 247 | |
| 237 | | if ( ! is_wp_error( $editor ) ) { |
| 238 | | $metadata['sizes'] = $editor->multi_resize( $sizes ); |
| 239 | | $metadata['sizes']['full'] = $uploaded; |
| | 248 | if ( ! is_wp_error( $editor ) && ! empty( $fallback_sizes ) ) { |
| | 249 | $metadata['sizes'] = $editor->multi_resize( $sizes ); |
| | 250 | $metadata['sizes']['full'] = $uploaded; |
| | 251 | } |
| 240 | 252 | } |
| 241 | 253 | } |
| 242 | 254 | } |