diff --git a/wp-admin/css/media.css b/wp-admin/css/media.css index d04866afe..172342d83 100644 --- a/wp-admin/css/media.css +++ b/wp-admin/css/media.css @@ -83,9 +83,17 @@ th { position: relative; } 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 @@ abbr.required { padding: 1em 0; } -#media-upload p.help { +#media-upload p.help, #media-upload label.help { font-style: italic; font-weight: normal; } diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 588095688..ddba1c373 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -96,7 +96,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { $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) { diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index f9c1bace9..db0f5e0c4 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -520,6 +520,41 @@ function media_upload_library() { 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 = "
"; + + $html .= ""; + // only show the dimensions if that choice is available + if ( $enabled ) + $html .= " "; + + $html .= '
'; + + $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; @@ -529,8 +564,6 @@ function image_attachment_fields_to_edit($form_fields, $post) { $form_fields['post_content']['label'] = __('Description'); - $thumb = wp_get_attachment_thumb_url($post->ID); - $form_fields['align'] = array( 'label' => __('Alignment'), 'input' => 'html', @@ -544,17 +577,7 @@ function image_attachment_fields_to_edit($form_fields, $post) { \n", ); - $form_fields['image-size'] = array( - 'label' => __('Size'), - 'input' => 'html', - 'html' => " - " . ( $thumb ? " - - " : '' ) . " - - - ", - ); + $form_fields['image-size'] = image_size_input_fields($post); } return $form_fields; } diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index c5b738346..4e75d5678 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -258,6 +258,10 @@ function populate_options() { 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) : diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php index 7497a1c02..42c04a713 100644 --- a/wp-admin/options-misc.php +++ b/wp-admin/options-misc.php @@ -62,6 +62,15 @@ include('admin-header.php'); + + +
+ + + + +
+ diff --git a/wp-includes/media.php b/wp-includes/media.php index b817a225f..95c52c070 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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 @@ function image_constrain_size_for_editor($width, $height, $size = 'medium') { $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 @@ function image_hwstring($width, $height) { // 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 @@ function image_downsize($id, $size = 'medium') { $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 @@ function image_downsize($id, $size = 'medium') { $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 @@ function image_downsize($id, $size = 'medium') { $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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 223c085a5..ddd110844 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -15,6 +15,6 @@ $wp_version = '2.7-bleeding'; * * @global int $wp_db_version */ -$wp_db_version = 8539; +$wp_db_version = 8585; ?>