Changeset 38949 for trunk/src/wp-admin/includes/image.php
- Timestamp:
- 10/26/2016 07:27:51 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r38333 r38949 77 77 $metadata = array(); 78 78 $support = false; 79 if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) { 79 $mime_type = get_post_mime_type( $attachment ); 80 81 if ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) { 80 82 $imagesize = getimagesize( $file ); 81 83 $metadata['width'] = $imagesize[0]; … … 202 204 } 203 205 } 206 // Try to create image thumbnails for PDFs 207 else if ( 'application/pdf' === $mime_type ) { 208 $editor = wp_get_image_editor( $file ); 209 210 $fallback_sizes = array( 211 'thumbnail', 212 'medium', 213 'large', 214 ); 215 216 $sizes = array(); 217 218 foreach ( $fallback_sizes as $s ) { 219 $sizes[$s]['width'] = get_option( "{$s}_size_w" ); 220 $sizes[$s]['height'] = get_option( "{$s}_size_h" ); 221 222 // Force thumbnails to be soft crops. 223 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; 240 } 241 } 242 } 243 } 204 244 205 245 // Remove the blob of binary data from the array.
Note: See TracChangeset
for help on using the changeset viewer.