Problem with WordPress 2.7.1 and images

I didn’t speak about the release of WordPress 2.7.1, because a lot of blogs already published the announce. This version adds a bug: all the attachments stored elsewhere the directory displayed in the menu Options/Misc cannot be displayed or reached.

In this blog, all galeries don’t work properly, and all images that are not displayed in their original size.

Waiting the version 2.7.2, you can solve this bug, by modifying the file wp-includes/post.php. You have to comment the lines that was added between the 2.7.0 and the 2.7.1 version (line 2533 of the file):

function wp_get_attachment_url( $post_id = 0 ) {
	$post_id = (int) $post_id;
	if ( !$post =& get_post( $post_id ) )
		return false;
	$url = '';
	if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { //Get attached file
		if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory
			if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location
				$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location
//			elseif ( false !== strpos($file, 'wp-content/uploads') )
//				$url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
//			else
//				$url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
	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.
		$url = get_the_guid( $post->ID );
	if ( 'attachment' != $post->post_type || empty($url) )
		return false;
	return apply_filters( 'wp_get_attachment_url', $url, $post->ID );

With this modification, images are displayed again.

Make a backup of the file post.php before any modification. With this backup, you will be able to rollback, if you encountered another problems.