Index: wp-includes/version.php
===================================================================
--- wp-includes/version.php	(revision 8585)
+++ wp-includes/version.php	(working copy)
@@ -15,6 +15,6 @@
  *
  * @global int $wp_db_version
  */
-$wp_db_version = 8539;
+$wp_db_version = 8585;
 
 ?>
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 8585)
+++ wp-includes/media.php	(working copy)
@@ -4,6 +4,7 @@
 
 // scale down the default size of an image so it's a better fit for the editor and theme
 function image_constrain_size_for_editor($width, $height, $size = 'medium') {
+	global $content_width;
 
 	if ( is_array($size) ) {
 		$max_width = $size[0];
@@ -23,19 +24,23 @@
 		$max_height = intval(get_option('medium_size_h'));
 		// if no width is set, default to the theme content width if available
 	}
-	else { // $size == 'full'
-		// we're inserting a full size image into the editor.  if it's a really big image we'll scale it down to fit reasonably
+	elseif ( $size == 'large' ) {
+		// we're inserting a large size image into the editor.  if it's a really big image we'll scale it down to fit reasonably
 		// within the editor itself, and within the theme's content width if it's known.  the user can resize it in the editor
 		// if they wish.
-		if ( !empty($GLOBALS['content_width']) ) {
-			$max_width = $GLOBALS['content_width'];
-		}
-		else
-			$max_width = 500;
+		$max_width = intval(get_option('large_size_w'));
+		$max_height = intval(get_option('large_size_h'));
+		if ( intval($content_width) > 0 )
+			$max_width = min( intval($content_width), $max_width );
 	}
+	// $size == 'full' has no constraint
+	else {
+		$max_width = $width;
+		$max_height = $height;
+	}
 
 	list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size );
-
+	
 	return wp_constrain_dimensions( $width, $height, $max_width, $max_height );
 }
 
@@ -51,7 +56,8 @@
 
 // Scale an image to fit a particular size (such as 'thumb' or 'medium'), and return an image URL, height and width.
 // The URL might be the original image, or it might be a resized version.  This function won't create a new resized copy, it will just return an already resized one if it exists.
-// returns an array($url, $width, $height)
+// returns an array($url, $width, $height, $is_intermediate)
+// $is_intermediate is true if $url is a resized image, false if it is the original
 function image_downsize($id, $size = 'medium') {
 
 	if ( !wp_attachment_is_image($id) )
@@ -60,6 +66,7 @@
 	$img_url = wp_get_attachment_url($id);
 	$meta = wp_get_attachment_metadata($id);
 	$width = $height = 0;
+	$is_intermediate = false;
 
 	// plugins can use this to provide resize services
 	if ( $out = apply_filters('image_downsize', false, $id, $size) )
@@ -70,6 +77,7 @@
 		$img_url = str_replace(basename($img_url), $intermediate['file'], $img_url);
 		$width = $intermediate['width'];
 		$height = $intermediate['height'];
+		$is_intermediate = true;
 	}
 	elseif ( $size == 'thumbnail' ) {
 		// fall back to the old thumbnail
@@ -77,15 +85,21 @@
 			$img_url = str_replace(basename($img_url), basename($thumb_file), $img_url);
 			$width = $info[0];
 			$height = $info[1];
+			$is_intermediate = true;
 		}
 	}
 	if ( !$width && !$height && isset($meta['width'], $meta['height']) ) {
-		// any other type: use the real image and constrain it
-		list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size );
+		// any other type: use the real image
+		$width = $meta['width'];
+		$height = $meta['height'];
 	}
+	
+	if ( $img_url) {
+		// we have the actual image size, but might need to further constrain it if content_width is narrower
+		list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
 
-	if ( $img_url)
-		return array( $img_url, $width, $height );
+		return array( $img_url, $width, $height, $is_intermediate );
+	}
 	return false;
 
 }
Index: wp-admin/includes/schema.php
===================================================================
--- wp-admin/includes/schema.php	(revision 8585)
+++ wp-admin/includes/schema.php	(working copy)
@@ -258,6 +258,10 @@
 	add_option('enable_app', 0);
 	add_option('enable_xmlrpc', 0);
 	
+	// 2.7
++ 	add_option('large_size_w', 1024);
++ 	add_option('large_size_h', 1024);
+	
 	// Delete unused options
 	$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins');
 	foreach ($unusedoptions as $option) :
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 8585)
+++ wp-admin/includes/media.php	(working copy)
@@ -505,6 +505,41 @@
 	return wp_iframe( 'media_upload_library_form', $errors );
 }
 
+function image_size_input_fields($post, $checked='') {
+		
+		// get a list of the actual pixel dimensions of each possible intermediate version of this image
+		$sizes = array();
+		$size_names = array('thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size');
+		
+		foreach ( $size_names as $size => $name) {
+			$downsize = image_downsize($post->ID, $size);
+			
+			// is this size selectable?
+			$enabled = ( $downsize[3] || 'full' == $size );
+			$css_id = "image-size-{$size}-{$post->ID}";
+			// if $checked was not specified, default to the first available size that's bigger than a thumbnail
+			if ( !$checked && $enabled && 'thumbnail' != $size )
+				$checked = $size;
+			
+			$html = "<div class='image-size-item'><input type='radio' ".( $enabled ? '' : "disabled='disabled'")."name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'".( $checked == $size ? " checked='checked'" : '') ." />";
+			
+			$html .= "<label for='{$css_id}'>" . __($name). "</label>";
+			// only show the dimensions if that choice is available
+			if ( $enabled )
+				$html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d&nbsp;&times;&nbsp;%d)"), $downsize[1], $downsize[2] ). "</label>";
+				
+			$html .= '</div>';
+		
+			$out[] = $html;
+		}
+		
+		return array(
+			'label' => __('Size'),
+			'input' => 'html',
+			'html'  => join("\n", $out),
+		);
+}
+
 function image_attachment_fields_to_edit($form_fields, $post) {
 	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
 		$form_fields['post_title']['required'] = true;
@@ -514,8 +549,6 @@
 
 		$form_fields['post_content']['label'] = __('Description');
 
-		$thumb = wp_get_attachment_thumb_url($post->ID);
-
 		$form_fields['align'] = array(
 			'label' => __('Alignment'),
 			'input' => 'html',
@@ -529,17 +562,7 @@
 				<input type='radio' name='attachments[$post->ID][align]' id='image-align-right-$post->ID' value='right' />
 				<label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n",
 		);
-		$form_fields['image-size'] = array(
-			'label' => __('Size'),
-			'input' => 'html',
-			'html'  => "
-				" . ( $thumb ? "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-thumb-$post->ID' value='thumbnail' />
-				<label for='image-size-thumb-$post->ID'>" . __('Thumbnail') . "</label>
-				" : '' ) . "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-medium-$post->ID' value='medium' checked='checked' />
-				<label for='image-size-medium-$post->ID'>" . __('Medium') . "</label>
-				<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-full-$post->ID' value='full' />
-				<label for='image-size-full-$post->ID'>" . __('Full size') . "</label>",
-		);
+		$form_fields['image-size'] = image_size_input_fields($post);
 	}
 	return $form_fields;
 }
Index: wp-admin/includes/image.php
===================================================================
--- wp-admin/includes/image.php	(revision 8585)
+++ wp-admin/includes/image.php	(working copy)
@@ -96,7 +96,7 @@
 		$metadata['file'] = $file;
 
 		// make thumbnails and other intermediate sizes
-		$sizes = array('thumbnail', 'medium');
+		$sizes = array('thumbnail', 'medium', 'large');
 		$sizes = apply_filters('intermediate_image_sizes', $sizes);
 		
 		foreach ($sizes as $size) {
Index: wp-admin/options-misc.php
===================================================================
--- wp-admin/options-misc.php	(revision 8585)
+++ wp-admin/options-misc.php	(working copy)
@@ -62,6 +62,15 @@
 <input name="medium_size_h" type="text" id="medium_size_h" value="<?php form_option('medium_size_h'); ?>" size="6" />
 </fieldset></td>
 </tr>
+<tr valign="top">
+<th scope="row"><?php _e('Large size') ?></th>
+<td><fieldset><legend class="hidden"><?php _e('Large size') ?></legend>
+<label for="large_size_w"><?php _e('Max Width'); ?></label>
+<input name="large_size_w" type="text" id="large_size_w" value="<?php form_option('large_size_w'); ?>" size="6" />
+<label for="large_size_h"><?php _e('Max Height'); ?></label>
+<input name="large_size_h" type="text" id="large_size_h" value="<?php form_option('large_size_h'); ?>" size="6" />
+</fieldset></td>
+</tr>
 </table>
 
 
Index: wp-admin/css/media.css
===================================================================
--- wp-admin/css/media.css	(revision 8585)
+++ wp-admin/css/media.css	(working copy)
@@ -83,9 +83,17 @@
 	display: none;
 }
 
+tr.image-size td {
+	width: 460px;
+}
+tr.image-size div.image-size-item {
+	float: left;
+	width: 25%;
+	margin: 0;
+}
 tr.image-size label {
 	display: inline;
-	margin: 0 1em 0 0;
+	margin: 0 0 0 1em;
 }
 .pinkynail {
 	max-width: 40px;
@@ -202,7 +210,7 @@
 	padding: 1em 0;
 }
 
-#media-upload p.help {
+#media-upload p.help, #media-upload label.help {
 	font-style: italic;
 	font-weight: normal;
 }

