Ticket #20555: 20555.patch
File 20555.patch, 1.5 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/image.php
50 50 // If the file doesn't exist, attempt a url fopen on the src link. 51 51 // This can occur with certain file replication plugins. 52 52 $post = get_post( $src ); 53 $image_type = $post->post_mime_type; 53 54 $src = load_image_to_edit( $src, $post->post_mime_type, 'full' ); 54 55 } else { 56 $size = @getimagesize( $src_file ); 57 $image_type = ( $size ) ? $size['mime'] : ''; 55 58 $src = wp_load_image( $src_file ); 56 59 } 57 60 } else { 61 $size = @getimagesize( $src ); 62 $image_type = ( $size ) ? $size['mime'] : ''; 58 63 $src = wp_load_image( $src ); 59 64 } 60 65 … … 78 83 if ( ! $dst_file ) 79 84 $dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file ); 80 85 81 $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); 86 if ( 'image/png' != $image_type ) 87 $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); 82 88 83 89 // The directory containing the original file may no longer exist when 84 90 // using a replication plugin. 85 91 wp_mkdir_p( dirname( $dst_file ) ); 86 92 87 if ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' )) )93 if ( 'image/png' == $image_type && imagepng( $dst, $dst_file ) ) 88 94 return $dst_file; 95 elseif ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) ) 96 return $dst_file; 89 97 else 90 98 return false; 91 99 }