Ticket #19840: 19840.18.diff
File 19840.18.diff, 5.8 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/image-edit.php
197 197 <?php 198 198 } 199 199 200 function load_image_to_edit($post_id, $mime_type, $size = 'full') {201 $filepath = get_attached_file($post_id);202 203 if ( $filepath && file_exists($filepath) ) {204 if ( 'full' != $size && ( $data = image_get_intermediate_size($post_id, $size) ) ) {205 $filepath = apply_filters('load_image_to_edit_filesystempath', path_join( dirname($filepath), $data['file'] ), $post_id, $size);206 }207 } elseif ( function_exists('fopen') && function_exists('ini_get') && true == ini_get('allow_url_fopen') ) {208 $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($post_id) , $post_id, $size);209 }210 211 $filepath = apply_filters('load_image_to_edit_path', $filepath, $post_id, $size);212 if ( empty($filepath) )213 return false;214 215 switch ( $mime_type ) {216 case 'image/jpeg':217 $image = imagecreatefromjpeg($filepath);218 break;219 case 'image/png':220 $image = imagecreatefrompng($filepath);221 break;222 case 'image/gif':223 $image = imagecreatefromgif($filepath);224 break;225 default:226 $image = false;227 break;228 }229 if ( is_resource($image) ) {230 $image = apply_filters('load_image_to_edit', $image, $post_id, $size);231 if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {232 imagealphablending($image, false);233 imagesavealpha($image, true);234 }235 }236 return $image;237 }238 239 200 function wp_stream_image($image, $mime_type, $post_id) { 240 201 $image = apply_filters('image_save_pre', $image, $post_id); 241 202 -
wp-admin/includes/image.php
43 43 * @param string $dst_file Optional. The destination file to write to. 44 44 * @return string|WP_Error|false New filepath on success, WP_Error or false on failure. 45 45 */ 46 function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { 47 if ( is_numeric( $src_file ) ) // Handle int as attachment ID 48 $src_file = get_attached_file( $src_file ); 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 ( is_numeric( $src ) ) { // Handle int as attachment ID 48 $src_file = get_attached_file( $src ); 49 if ( ! file_exists( $src_file ) ) { 50 $post = get_post( $src ); 51 $src = load_image_to_edit( $src, $post->post_mime_type, 'full'); 52 } else { 53 $src = wp_load_image( $src_file ); 54 } 55 } else { 56 $src = wp_load_image( $src_file ); 57 } 49 58 50 $src = wp_load_image( $src_file );51 52 59 if ( !is_resource( $src ) ) 53 60 return new WP_Error( 'error_loading_image', $src, $src_file ); 54 61 … … 71 78 72 79 $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); 73 80 81 wp_mkdir_p( dirname( $dst_file ) ); 82 74 83 if ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) ) 75 84 return $dst_file; 76 85 else … … 339 348 340 349 return apply_filters('file_is_displayable_image', $result, $path); 341 350 } 351 352 function load_image_to_edit($post_id, $mime_type, $size = 'full') { 353 $filepath = get_attached_file($post_id); 354 355 if ( $filepath && file_exists($filepath) ) { 356 if ( 'full' != $size && ( $data = image_get_intermediate_size($post_id, $size) ) ) { 357 $filepath = apply_filters('load_image_to_edit_filesystempath', path_join( dirname($filepath), $data['file'] ), $post_id, $size); 358 } 359 } elseif ( function_exists('fopen') && function_exists('ini_get') && true == ini_get('allow_url_fopen') ) { 360 $filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($post_id) , $post_id, $size); 361 } 362 363 $filepath = apply_filters('load_image_to_edit_path', $filepath, $post_id, $size); 364 if ( empty($filepath) ) 365 return false; 366 367 switch ( $mime_type ) { 368 case 'image/jpeg': 369 $image = imagecreatefromjpeg($filepath); 370 break; 371 case 'image/png': 372 $image = imagecreatefrompng($filepath); 373 break; 374 case 'image/gif': 375 $image = imagecreatefromgif($filepath); 376 break; 377 default: 378 $image = false; 379 break; 380 } 381 if ( is_resource($image) ) { 382 $image = apply_filters('load_image_to_edit', $image, $post_id, $size); 383 if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) { 384 imagealphablending($image, false); 385 imagesavealpha($image, true); 386 } 387 } 388 return $image; 389 } -
wp-admin/custom-header.php
700 700 extract($this->step_2_manage_upload()); 701 701 } 702 702 703 list($width, $height, $type, $attr) = getimagesize( $file ); 703 if ( file_exists( $file ) ) { 704 list( $width, $height, $type, $attr ) = getimagesize( $file ); 705 } else { 706 $data = wp_get_attachment_metadata( $id ); 707 $height = $data[ 'height' ]; 708 $width = $data[ 'width' ]; 709 } 704 710 705 711 $max_width = 0; 706 712 // For flex, limit size of image displayed to 1500px unless theme says otherwise … … 724 730 return $this->finished(); 725 731 } elseif ( $width > $max_width ) { 726 732 $oitar = $width / $max_width; 727 $image = wp_crop_image($ file, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file));733 $image = wp_crop_image($id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); 728 734 if ( is_wp_error( $image ) ) 729 735 wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); 730 736