Changeset 20706
- Timestamp:
- 05/02/2012 09:35:56 PM (13 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-header.php
r20384 r20706 859 859 $url = str_replace(basename($parent_url), basename($cropped), $parent_url); 860 860 861 $size = @getimagesize( $cropped ); 862 $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; 863 861 864 // Construct the object array 862 865 $object = array( … … 864 867 'post_title' => basename($cropped), 865 868 'post_content' => $url, 866 'post_mime_type' => 'image/jpeg',869 'post_mime_type' => $image_type, 867 870 'guid' => $url, 868 871 'context' => 'custom-header' -
trunk/wp-admin/includes/image.php
r20454 r20706 45 45 */ 46 46 function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { 47 if ( 0 == $src_x && 0 == $src_y && $src_w == $dst_w && $src_h == $dst_h ) 48 return ( is_numeric( $src ) ) ? get_attached_file( $src ) : $src; 49 47 50 if ( is_numeric( $src ) ) { // Handle int as attachment ID 48 51 $src_file = get_attached_file( $src ); … … 51 54 // This can occur with certain file replication plugins. 52 55 $post = get_post( $src ); 56 $image_type = $post->post_mime_type; 53 57 $src = load_image_to_edit( $src, $post->post_mime_type, 'full' ); 54 58 } else { 59 $size = @getimagesize( $src_file ); 60 $image_type = ( $size ) ? $size['mime'] : ''; 55 61 $src = wp_load_image( $src_file ); 56 62 } 57 63 } else { 64 $size = @getimagesize( $src ); 65 $image_type = ( $size ) ? $size['mime'] : ''; 58 66 $src = wp_load_image( $src ); 59 67 } … … 79 87 $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file ); 80 88 81 $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); 89 if ( 'image/png' != $image_type ) 90 $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); 82 91 83 92 // The directory containing the original file may no longer exist when … … 85 94 wp_mkdir_p( dirname( $dst_file ) ); 86 95 87 if ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) ) 96 if ( 'image/png' == $image_type && imagepng( $dst, $dst_file ) ) 97 return $dst_file; 98 elseif ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) ) 88 99 return $dst_file; 89 100 else
Note: See TracChangeset
for help on using the changeset viewer.