Changeset 39246
- Timestamp:
- 11/15/2016 01:25:46 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r38949 r39246 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', … … 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 ) { 219 $sizes[ $s]['width'] = get_option( "{$s}_size_w" );220 $sizes[ $s]['height'] = get_option( "{$s}_size_h" );226 $sizes[ $s ]['width'] = get_option( "{$s}_size_w" ); 227 $sizes[ $s ]['height'] = get_option( "{$s}_size_h" ); 221 228 222 229 // Force thumbnails to be soft crops. 223 230 if ( ! 'thumbnail' === $s ) { 224 $sizes[$s]['crop'] = get_option( "{$s}_crop" ); 225 } 226 } 227 228 if ( ! is_wp_error( $editor ) ) { // No support for this type of file 229 $uploaded = $editor->save( $file, 'image/jpeg' ); 230 unset( $editor ); 231 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'] ); 236 237 if ( ! is_wp_error( $editor ) ) { 238 $metadata['sizes'] = $editor->multi_resize( $sizes ); 239 $metadata['sizes']['full'] = $uploaded; 231 $sizes[ $s ]['crop'] = get_option( "{$s}_crop" ); 232 } 233 } 234 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 ); 242 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'] ); 247 248 if ( ! is_wp_error( $editor ) ) { 249 $metadata['sizes'] = $editor->multi_resize( $sizes ); 250 $metadata['sizes']['full'] = $uploaded; 251 } 240 252 } 241 253 }
Note: See TracChangeset
for help on using the changeset viewer.