Ticket #7151: large-size-images-r8111.patch
File large-size-images-r8111.patch, 10.5 KB (added by , 16 years ago) |
---|
-
wp-includes/version.php
16 16 * 17 17 * @global int $wp_db_version 18 18 */ 19 $wp_db_version = 8 000;19 $wp_db_version = 8111; 20 20 21 21 ?> -
wp-includes/media.php
4 4 5 5 // scale down the default size of an image so it's a better fit for the editor and theme 6 6 function image_constrain_size_for_editor($width, $height, $size = 'medium') { 7 global $content_width; 7 8 8 9 if ( is_array($size) ) { 9 10 $max_width = $size[0]; … … 23 24 $max_height = intval(get_option('medium_size_h')); 24 25 // if no width is set, default to the theme content width if available 25 26 } 26 else { // $size == 'full'27 // we're inserting a fullsize image into the editor. if it's a really big image we'll scale it down to fit reasonably27 elseif ( $size == 'large' ) { 28 // 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 28 29 // within the editor itself, and within the theme's content width if it's known. the user can resize it in the editor 29 30 // if they wish. 30 if ( !empty($GLOBALS['content_width']) ) { 31 $max_width = $GLOBALS['content_width']; 32 } 33 else 34 $max_width = 500; 31 $max_width = intval(get_option('large_size_w')); 32 $max_height = intval(get_option('large_size_h')); 33 if ( intval($content_width) > 0 ) 34 $max_width = min( intval($content_width), $max_width ); 35 35 } 36 // $size == 'full' has no constraint 37 else { 38 $max_width = $width; 39 $max_height = $height; 40 } 36 41 37 42 list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size ); 38 43 39 44 return wp_constrain_dimensions( $width, $height, $max_width, $max_height ); 40 45 } 41 46 … … 51 56 52 57 // Scale an image to fit a particular size (such as 'thumb' or 'medium'), and return an image URL, height and width. 53 58 // 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. 54 // returns an array($url, $width, $height) 59 // returns an array($url, $width, $height, $is_intermediate) 60 // $is_intermediate is true if $url is a resized image, false if it is the original 55 61 function image_downsize($id, $size = 'medium') { 56 62 57 63 if ( !wp_attachment_is_image($id) ) … … 60 66 $img_url = wp_get_attachment_url($id); 61 67 $meta = wp_get_attachment_metadata($id); 62 68 $width = $height = 0; 69 $is_intermediate = false; 63 70 64 71 // plugins can use this to provide resize services 65 72 if ( $out = apply_filters('image_downsize', false, $id, $size) ) … … 70 77 $img_url = str_replace(basename($img_url), $intermediate['file'], $img_url); 71 78 $width = $intermediate['width']; 72 79 $height = $intermediate['height']; 80 $is_intermediate = true; 73 81 } 74 82 elseif ( $size == 'thumbnail' ) { 75 83 // fall back to the old thumbnail … … 77 85 $img_url = str_replace(basename($img_url), basename($thumb_file), $img_url); 78 86 $width = $info[0]; 79 87 $height = $info[1]; 88 $is_intermediate = true; 80 89 } 81 90 } 82 91 if ( !$width && !$height && isset($meta['width'], $meta['height']) ) { 83 // any other type: use the real image and constrain it 84 list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'], $size ); 92 // any other type: use the real image 93 $width = $meta['width']; 94 $height = $meta['height']; 85 95 } 96 97 if ( $img_url) { 98 // we have the actual image size, but might need to further constrain it if content_width is narrower 99 list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size ); 86 100 87 if ( $img_url)88 return array( $img_url, $width, $height );101 return array( $img_url, $width, $height, $is_intermediate ); 102 } 89 103 return false; 90 104 91 105 } -
wp-admin/includes/schema.php
255 255 256 256 // 2.6 257 257 add_option('avatar_default', 'mystery'); 258 add_option('large_size_w', 1024); 259 add_option('large_size_h', 1024); 258 260 259 261 // Delete unused options 260 262 $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'); -
wp-admin/includes/media.php
489 489 return wp_iframe( 'media_upload_library_form', $errors ); 490 490 } 491 491 492 function image_size_input_fields($post, $checked='') { 493 494 // get a list of the actual pixel dimensions of each possible intermediate version of this image 495 $sizes = array(); 496 $size_names = array('thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size'); 497 498 foreach ( $size_names as $size => $name) { 499 $downsize = image_downsize($post->ID, $size); 500 501 // is this size selectable? 502 $enabled = ( $downsize[3] || 'full' == $size ); 503 $css_id = "image-size-{$size}-{$post->ID}"; 504 // if $checked was not specified, default to the first available size that's bigger than a thumbnail 505 if ( !$checked && $enabled && 'thumbnail' != $size ) 506 $checked = $size; 507 508 $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'" : '') ." />"; 509 510 $html .= "<label for='{$css_id}'>" . __($name). "</label>"; 511 // only show the dimensions if that choice is available 512 if ( $enabled ) 513 $html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d × %d)"), $downsize[1], $downsize[2] ). "</label>"; 514 515 $html .= '</div>'; 516 517 $out[] = $html; 518 } 519 520 return array( 521 'label' => __('Size'), 522 'input' => 'html', 523 'html' => join("\n", $out), 524 ); 525 } 526 492 527 function image_attachment_fields_to_edit($form_fields, $post) { 493 528 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 494 529 $form_fields['post_title']['required'] = true; … … 497 532 498 533 $form_fields['post_content']['label'] = __('Description'); 499 534 500 $thumb = wp_get_attachment_thumb_url($post->ID);501 502 535 $form_fields['align'] = array( 503 536 'label' => __('Alignment'), 504 537 'input' => 'html', … … 512 545 <input type='radio' name='attachments[$post->ID][align]' id='image-align-right-$post->ID' value='right' /> 513 546 <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n", 514 547 ); 515 $form_fields['image-size'] = array( 516 'label' => __('Size'), 517 'input' => 'html', 518 'html' => " 519 " . ( $thumb ? "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-thumb-$post->ID' value='thumbnail' /> 520 <label for='image-size-thumb-$post->ID'>" . __('Thumbnail') . "</label> 521 " : '' ) . "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-medium-$post->ID' value='medium' checked='checked' /> 522 <label for='image-size-medium-$post->ID'>" . __('Medium') . "</label> 523 <input type='radio' name='attachments[$post->ID][image-size]' id='image-size-full-$post->ID' value='full' /> 524 <label for='image-size-full-$post->ID'>" . __('Full size') . "</label>", 525 ); 548 $form_fields['image-size'] = image_size_input_fields($post); 526 549 } 527 550 return $form_fields; 528 551 } -
wp-admin/includes/image.php
96 96 $metadata['file'] = $file; 97 97 98 98 // make thumbnails and other intermediate sizes 99 $sizes = array('thumbnail', 'medium' );99 $sizes = array('thumbnail', 'medium', 'large'); 100 100 $sizes = apply_filters('intermediate_image_sizes', $sizes); 101 101 102 102 foreach ($sizes as $size) { -
wp-admin/options-misc.php
62 62 <input name="medium_size_h" type="text" id="medium_size_h" value="<?php form_option('medium_size_h'); ?>" size="6" /> 63 63 </fieldset></td> 64 64 </tr> 65 <tr valign="top"> 66 <th scope="row"><?php _e('Large size') ?></th> 67 <td><fieldset><legend class="hidden"><?php _e('Large size') ?></legend> 68 <label for="large_size_w"><?php _e('Max Width'); ?></label> 69 <input name="large_size_w" type="text" id="large_size_w" value="<?php form_option('large_size_w'); ?>" size="6" /> 70 <label for="large_size_h"><?php _e('Max Height'); ?></label> 71 <input name="large_size_h" type="text" id="large_size_h" value="<?php form_option('large_size_h'); ?>" size="6" /> 72 </fieldset></td> 73 </tr> 65 74 </table> 66 75 67 76 -
wp-admin/css/media.css
82 82 display: none; 83 83 } 84 84 85 tr.image-size td { 86 width: 460px; 87 } 88 tr.image-size div.image-size-item { 89 float: left; 90 width: 25%; 91 margin: 0; 92 } 85 93 tr.image-size label { 86 94 display: inline; 87 margin: 0 1em 0 0;95 margin: 0 0 0 1em; 88 96 } 89 97 .pinkynail { 90 98 max-width: 40px; … … 201 209 padding: 1em 0; 202 210 } 203 211 204 #media-upload p.help {212 #media-upload p.help, #media-upload label.help { 205 213 font-style: italic; 206 214 font-weight: normal; 207 215 }