Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 16382)
+++ wp-admin/includes/media.php	(working copy)
@@ -283,10 +283,9 @@
 
 	// Save the attachment metadata
 	$id = wp_insert_attachment($attachment, $file, $post_id);
-	if ( !is_wp_error($id) ) {
+	if ( !is_wp_error($id) )
 		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
-		return $url;
-	}
+
 	return $id;
 }
 
@@ -518,20 +517,21 @@
 		$file_array['tmp_name'] = $tmp;
 
 		// If error storing temporarily, unlink
-		if ( is_wp_error($tmp) ) {
+		if ( is_wp_error( $tmp ) ) {
 			@unlink($file_array['tmp_name']);
 			$file_array['tmp_name'] = '';
 		}
 
 		// do the validation and storage stuff
-		$id = media_handle_sideload($file_array, $post_id, @$desc);
-		$src = $id;
+		$id = media_handle_sideload( $file_array, $post_id, @$desc );
 
 		// If error storing permanently, unlink
 		if ( is_wp_error($id) ) {
 			@unlink($file_array['tmp_name']);
 			return $id;
 		}
+
+		$src = get_attachment_link( $id );
 	}
 
 	// Finally check to make sure the file has been saved, then return the html
