| 1 | Index: media.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- media.php (revision 16973) |
|---|
| 4 | +++ media.php (working copy) |
|---|
| 5 | @@ -145,7 +145,7 @@ |
|---|
| 6 | |
|---|
| 7 | // try for a new style intermediate size |
|---|
| 8 | if ( $intermediate = image_get_intermediate_size($id, $size) ) { |
|---|
| 9 | - $img_url = str_replace($img_url_basename, $intermediate['file'], $img_url); |
|---|
| 10 | + $img_url = str_replace($img_url_basename, urlencode( $intermediate['file'] ), $img_url); |
|---|
| 11 | $width = $intermediate['width']; |
|---|
| 12 | $height = $intermediate['height']; |
|---|
| 13 | $is_intermediate = true; |
|---|
| 14 | @@ -153,7 +153,7 @@ |
|---|
| 15 | elseif ( $size == 'thumbnail' ) { |
|---|
| 16 | // fall back to the old thumbnail |
|---|
| 17 | if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) { |
|---|
| 18 | - $img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url); |
|---|
| 19 | + $img_url = str_replace($img_url_basename, urlencode( wp_basename($thumb_file) ), $img_url); |
|---|
| 20 | $width = $info[0]; |
|---|
| 21 | $height = $info[1]; |
|---|
| 22 | $is_intermediate = true; |
|---|
| 23 | Index: post.php |
|---|
| 24 | =================================================================== |
|---|
| 25 | --- post.php (revision 16973) |
|---|
| 26 | +++ post.php (working copy) |
|---|
| 27 | @@ -3809,18 +3809,17 @@ |
|---|
| 28 | return false; |
|---|
| 29 | |
|---|
| 30 | $url = ''; |
|---|
| 31 | - if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { //Get attached file |
|---|
| 32 | - if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory |
|---|
| 33 | - if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location |
|---|
| 34 | - $url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location |
|---|
| 35 | - elseif ( false !== strpos($file, 'wp-content/uploads') ) |
|---|
| 36 | - $url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 ); |
|---|
| 37 | - else |
|---|
| 38 | - $url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir. |
|---|
| 39 | + if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true ) ) { // Get attached file |
|---|
| 40 | + if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory |
|---|
| 41 | + if ( 0 === strpos( $file, $uploads['basedir'] ) ) // Check that the upload base exists in the file location |
|---|
| 42 | + $file = substr( $file, strlen( $uploads['basedir'] ) + 1 ); |
|---|
| 43 | + elseif ( false !== strpos( $file, 'wp-content/uploads' ) ) |
|---|
| 44 | + $file = substr( $file, strpos($file, 'wp-content/uploads' ) + 19 ); |
|---|
| 45 | + $url = $uploads['baseurl'] . '/' . implode( '/', urlencode_deep( explode( '/', $file ) ) ); |
|---|
| 46 | } |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | - if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recomended to rely upon this. |
|---|
| 50 | + if ( empty($url) ) // If any of the above options failed, Fallback on the GUID as used pre-2.7, not recomended to rely upon this. |
|---|
| 51 | $url = get_the_guid( $post->ID ); |
|---|
| 52 | |
|---|
| 53 | $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID ); |
|---|