Ticket #35959: 35959.patch
File 35959.patch, 2.2 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/image.php
250 250 // Only load PDFs in an image editor if we're processing sizes. 251 251 if ( ! empty( $sizes ) ) { 252 252 $editor = wp_get_image_editor( $file ); 253 if ( is_wp_error( $editor ) ) { 254 // No support for this type of file. 255 return $editor; 256 } 253 257 254 if ( ! is_wp_error( $editor ) ) { // No support for this type of file 255 /* 256 * PDFs may have the same file filename as JPEGs. 257 * Ensure the PDF preview image does not overwrite any JPEG images that already exist. 258 */ 259 $dirname = dirname( $file ) . '/'; 260 $ext = '.' . pathinfo( $file, PATHINFO_EXTENSION ); 261 $preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' ); 258 /* 259 * PDFs may have the same file filename as JPEGs. 260 * Ensure the PDF preview image does not overwrite any JPEG images that already exist. 261 */ 262 $dirname = dirname( $file ) . '/'; 263 $ext = '.' . pathinfo( $file, PATHINFO_EXTENSION ); 264 $preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' ); 262 265 263 264 266 $uploaded = $editor->save( $preview_file, 'image/jpeg' ); 267 unset( $editor ); 265 268 266 // Resize based on the full size image, rather than the source. 267 if ( ! is_wp_error( $uploaded ) ) { 268 $editor = wp_get_image_editor( $uploaded['path'] ); 269 unset( $uploaded['path'] ); 269 if ( is_wp_error( $uploaded ) ) { 270 return $uploaded; 271 } 270 272 271 if ( ! is_wp_error( $editor ) ) { 272 $metadata['sizes'] = $editor->multi_resize( $sizes ); 273 $metadata['sizes']['full'] = $uploaded; 274 } 275 } 273 // Resize based on the full size image, rather than the source. 274 $editor = wp_get_image_editor( $uploaded['path'] ); 275 unset( $uploaded['path'] ); 276 277 if ( is_wp_error( $editor ) ) { 278 return $editor; 276 279 } 280 281 $metadata['sizes'] = $editor->multi_resize( $sizes ); 282 $metadata['sizes']['full'] = $uploaded; 277 283 } 278 284 } 279 285