Ticket #31050: 31050.patch
File 31050.patch, 3.9 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/image.php
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) ) { 81 $attachment_fallback_mimetypes = apply_filters( 'attachment_fallback_mimetypes', array( 'application/pdf', 'video/avi' ) ); 82 $mime_type = get_post_mime_type( $attachment ); 83 84 if ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image($file) ) { 82 85 $imagesize = getimagesize( $file ); 83 86 $metadata['width'] = $imagesize[0]; 84 87 $metadata['height'] = $imagesize[1]; … … 192 195 } 193 196 } 194 197 } 198 else if ( in_array( $mime_type, $attachment_fallback_mimetypes ) ) { 199 $editor = wp_get_image_editor( $file ); 195 200 201 if ( ! is_wp_error( $editor ) ) { // No support for this type of file 202 $uploaded = $editor->save( $file . '.jpg' ); 203 204 if ( ! is_wp_error( $uploaded ) ) { 205 unset( $uploaded['path'] ); 206 207 $metadata = array_merge( $metadata, $uploaded ); 208 $metadata['sizes'] = array( 209 'full' => $uploaded 210 ); 211 } 212 } 213 } 214 196 215 // Remove the blob of binary data from the array. 197 216 if ( $metadata ) { 198 217 unset( $metadata['image']['data'] ); -
src/wp-includes/media-template.php
290 290 <div class="thumbnail thumbnail-{{ data.type }}"> 291 291 <# if ( data.uploading ) { #> 292 292 <div class="media-progress-bar"><div></div></div> 293 <# } else if ( 'image' === data.type &&data.sizes && data.sizes.large ) { #>293 <# } else if ( data.sizes && data.sizes.large ) { #> 294 294 <img class="details-image" src="{{ data.sizes.large.url }}" draggable="false" alt="" /> 295 <# } else if ( 'image' === data.type &&data.sizes && data.sizes.full ) { #>295 <# } else if ( data.sizes && data.sizes.full ) { #> 296 296 <img class="details-image" src="{{ data.sizes.full.url }}" draggable="false" alt="" /> 297 297 <# } else if ( -1 === jQuery.inArray( data.type, [ 'audio', 'video' ] ) ) { #> 298 298 <img class="details-image icon" src="{{ data.icon }}" draggable="false" alt="" /> … … 450 450 <div class="centered"> 451 451 <img src="{{ data.size.url }}" draggable="false" alt="" /> 452 452 </div> 453 <# } else if ( data.sizes ) { #> 454 <div class="centered"> 455 <img src="{{ data.sizes.full.url }}" draggable="false" alt="" /> 456 </div> 453 457 <# } else { #> 454 458 <div class="centered"> 455 459 <# if ( data.image && data.image.src && data.image.src !== data.icon ) { #> -
src/wp-includes/media.php
1006 1006 */ 1007 1007 $image_meta = apply_filters( 'wp_calculate_image_srcset_meta', $image_meta, $size_array, $image_src, $attachment_id ); 1008 1008 1009 if ( empty( $image_meta[' sizes'] ) ) {1009 if ( empty( $image_meta['file'] ) || empty( $image_meta['sizes'] ) ) { 1010 1010 return false; 1011 1011 } 1012 1012 … … 3147 3147 } 3148 3148 3149 3149 $response = array_merge( $response, array( 'sizes' => $sizes ), $sizes['full'] ); 3150 } elseif ( $meta && 'video' === $type ) { 3150 } 3151 elseif ( isset( $meta['sizes'] ) ) { 3152 $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); 3153 3154 foreach ( $meta['sizes'] as $size => $data ) { 3155 $response['sizes'][ $size ] = array( 3156 'height' => $data['height'], 3157 'width' => $data['width'], 3158 'url' => $base_url . $data['file'], 3159 'orientation' => $data['height'] > $data['width'] ? 'portrait' : 'landscape', 3160 ); 3161 } 3162 } 3163 3164 if ( $meta && 'video' === $type ) { 3151 3165 if ( isset( $meta['width'] ) ) 3152 3166 $response['width'] = (int) $meta['width']; 3153 3167 if ( isset( $meta['height'] ) )