| 1 | Index: wp-includes/media.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/media.php (revision 15838) |
|---|
| 4 | +++ wp-includes/media.php (working copy) |
|---|
| 5 | @@ -144,7 +144,7 @@ |
|---|
| 6 | |
|---|
| 7 | // try for a new style intermediate size |
|---|
| 8 | if ( $intermediate = image_get_intermediate_size($id, $size) ) { |
|---|
| 9 | - $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url); |
|---|
| 10 | + $img_url = $intermediate['url']; |
|---|
| 11 | $width = $intermediate['width']; |
|---|
| 12 | $height = $intermediate['height']; |
|---|
| 13 | $is_intermediate = true; |
|---|
| 14 | @@ -523,6 +523,8 @@ |
|---|
| 15 | function image_get_intermediate_size($post_id, $size='thumbnail') { |
|---|
| 16 | if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) ) |
|---|
| 17 | return false; |
|---|
| 18 | + |
|---|
| 19 | + $file_url = wp_get_attachment_url($post_id); |
|---|
| 20 | |
|---|
| 21 | // get the best one for a specified set of dimensions |
|---|
| 22 | if ( is_array($size) && !empty($imagedata['sizes']) ) { |
|---|
| 23 | @@ -530,8 +532,10 @@ |
|---|
| 24 | // already cropped to width or height; so use this size |
|---|
| 25 | if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { |
|---|
| 26 | $file = $data['file']; |
|---|
| 27 | + if(!empty($data['path'])) $path = $data['path']; |
|---|
| 28 | + if(!empty($data['url'])) $url = $data['url']; |
|---|
| 29 | list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
|---|
| 30 | - return compact( 'file', 'width', 'height' ); |
|---|
| 31 | + return image_add_path_and_url_to_meta($file_url, $imagedata['file'], compact( 'file', 'width', 'height' , 'path', 'url')); |
|---|
| 32 | } |
|---|
| 33 | // add to lookup table: area => size |
|---|
| 34 | $areas[$data['width'] * $data['height']] = $_size; |
|---|
| 35 | @@ -550,8 +554,10 @@ |
|---|
| 36 | continue; |
|---|
| 37 | // If we're still here, then we're going to use this size |
|---|
| 38 | $file = $data['file']; |
|---|
| 39 | + if(!empty($data['path'])) $path = $data['path']; |
|---|
| 40 | + if(!empty($data['url'])) $url = $data['url']; |
|---|
| 41 | list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
|---|
| 42 | - return compact( 'file', 'width', 'height' ); |
|---|
| 43 | + return image_add_path_and_url_to_meta($file_url, $imagedata['file'], compact( 'file', 'width', 'height' , 'path', 'url')); |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | @@ -561,12 +567,15 @@ |
|---|
| 48 | return false; |
|---|
| 49 | |
|---|
| 50 | $data = $imagedata['sizes'][$size]; |
|---|
| 51 | - // include the full filesystem path of the intermediate file |
|---|
| 52 | - if ( empty($data['path']) && !empty($data['file']) ) { |
|---|
| 53 | - $file_url = wp_get_attachment_url($post_id); |
|---|
| 54 | - $data['path'] = path_join( dirname($imagedata['file']), $data['file'] ); |
|---|
| 55 | + return image_add_path_and_url_to_meta($file_url, $imagedata['file'], $data); |
|---|
| 56 | +} |
|---|
| 57 | + |
|---|
| 58 | +// include the full filesystem path of the intermediate file |
|---|
| 59 | +function image_add_path_and_url_to_meta($file_url, $file, $data){ |
|---|
| 60 | + if ( empty($data['path']) && !empty($data['file']) ) |
|---|
| 61 | + $data['path'] = path_join( dirname($file), $data['file'] ); |
|---|
| 62 | + if ( empty($data['url']) && !empty($data['file']) ) |
|---|
| 63 | $data['url'] = path_join( dirname($file_url), $data['file'] ); |
|---|
| 64 | - } |
|---|
| 65 | return $data; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | Index: wp-admin/includes/image-edit.php |
|---|
| 69 | =================================================================== |
|---|
| 70 | --- wp-admin/includes/image-edit.php (revision 15838) |
|---|
| 71 | +++ wp-admin/includes/image-edit.php (working copy) |
|---|
| 72 | @@ -202,7 +202,7 @@ |
|---|
| 73 | |
|---|
| 74 | if ( $filepath && file_exists($filepath) ) { |
|---|
| 75 | if ( 'full' != $size && ( $data = image_get_intermediate_size($post_id, $size) ) ) |
|---|
| 76 | - $filepath = path_join( dirname($filepath), $data['file'] ); |
|---|
| 77 | + $filepath = $data['path']; |
|---|
| 78 | } elseif ( WP_Http_Fopen::test() ) { |
|---|
| 79 | $filepath = wp_get_attachment_url($post_id); |
|---|
| 80 | } |
|---|