diff --git wp-admin/includes/image.php wp-admin/includes/image.php
index 4d9e076..6cf8502 100644
|
|
function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s |
73 | 73 | * @param string $file Filepath of the Attached image. |
74 | 74 | * @return mixed Metadata for attachment. |
75 | 75 | */ |
76 | | function wp_generate_attachment_metadata( $attachment_id, $file ) { |
| 76 | function wp_generate_attachment_metadata( $attachment_id, $file, $dimensions = false ) { |
77 | 77 | $attachment = get_post( $attachment_id ); |
78 | 78 | |
79 | 79 | $metadata = array(); |
80 | 80 | $support = false; |
81 | | if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) { |
82 | | $imagesize = getimagesize( $file ); |
83 | | $metadata['width'] = $imagesize[0]; |
84 | | $metadata['height'] = $imagesize[1]; |
| 81 | if ( preg_match( '!^image/!', get_post_mime_type( $attachment ) ) && ( file_is_displayable_image( $file ) || $dimensions ) ) { |
| 82 | if( ! $dimensions ) { |
| 83 | $imagesize = getimagesize( $file ); |
| 84 | $metadata['width'] = $imagesize[0]; |
| 85 | $metadata['height'] = $imagesize[1]; |
| 86 | } else { |
| 87 | $metadata['width'] = $dimensions['width']; |
| 88 | $metadata['height'] = $dimensions['height']; |
| 89 | } |
85 | 90 | |
86 | 91 | // Make the file path relative to the upload dir. |
87 | 92 | $metadata['file'] = _wp_relative_upload_path($file); |