WordPress.org

Make WordPress Core

Changeset 8612


Ignore:
Timestamp:
08/11/2008 03:54:26 AM (10 years ago)
Author:
ryan
Message:

Separate Large and Full image sizes. Props tellyworth. fixes #7151

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/media.css

    r8304 r8612  
    8484}
    8585
     86tr.image-size td {
     87    width: 460px;
     88}
     89tr.image-size div.image-size-item {
     90    float: left;
     91    width: 25%;
     92    margin: 0;
     93}
    8694tr.image-size label {
    8795    display: inline;
    88     margin: 0 1em 0 0;
     96    margin: 0 0 0 1em;
    8997}
    9098.pinkynail {
     
    203211}
    204212
    205 #media-upload p.help {
     213#media-upload p.help, #media-upload label.help {
    206214    font-style: italic;
    207215    font-weight: normal;
  • trunk/wp-admin/includes/image.php

    r8600 r8612  
    9797
    9898        // make thumbnails and other intermediate sizes
    99         $sizes = array('thumbnail', 'medium');
     99        $sizes = array('thumbnail', 'medium', 'large');
    100100        $sizes = apply_filters('intermediate_image_sizes', $sizes);
    101101
  • trunk/wp-admin/includes/media.php

    r8605 r8612  
    521521}
    522522
     523function image_size_input_fields($post, $checked='') {
     524       
     525        // get a list of the actual pixel dimensions of each possible intermediate version of this image
     526        $sizes = array();
     527        $size_names = array('thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size');
     528       
     529        foreach ( $size_names as $size => $name) {
     530            $downsize = image_downsize($post->ID, $size);
     531           
     532            // is this size selectable?
     533            $enabled = ( $downsize[3] || 'full' == $size );
     534            $css_id = "image-size-{$size}-{$post->ID}";
     535            // if $checked was not specified, default to the first available size that's bigger than a thumbnail
     536            if ( !$checked && $enabled && 'thumbnail' != $size )
     537                $checked = $size;
     538           
     539            $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'" : '') ." />";
     540           
     541            $html .= "<label for='{$css_id}'>" . __($name). "</label>";
     542            // only show the dimensions if that choice is available
     543            if ( $enabled )
     544                $html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d&nbsp;&times;&nbsp;%d)"), $downsize[1], $downsize[2] ). "</label>";
     545               
     546            $html .= '</div>';
     547       
     548            $out[] = $html;
     549        }
     550       
     551        return array(
     552            'label' => __('Size'),
     553            'input' => 'html',
     554            'html'  => join("\n", $out),
     555        );
     556}
     557
    523558function image_attachment_fields_to_edit($form_fields, $post) {
    524559    if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
     
    529564
    530565        $form_fields['post_content']['label'] = __('Description');
    531 
    532         $thumb = wp_get_attachment_thumb_url($post->ID);
    533566
    534567        $form_fields['align'] = array(
     
    545578                <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n",
    546579        );
    547         $form_fields['image-size'] = array(
    548             'label' => __('Size'),
    549             'input' => 'html',
    550             'html'  => "
    551                 " . ( $thumb ? "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-thumb-$post->ID' value='thumbnail' />
    552                 <label for='image-size-thumb-$post->ID'>" . __('Thumbnail') . "</label>
    553                 " : '' ) . "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-medium-$post->ID' value='medium' checked='checked' />
    554                 <label for='image-size-medium-$post->ID'>" . __('Medium') . "</label>
    555                 <input type='radio' name='attachments[$post->ID][image-size]' id='image-size-full-$post->ID' value='full' />
    556                 <label for='image-size-full-$post->ID'>" . __('Full size') . "</label>",
    557         );
     580        $form_fields['image-size'] = image_size_input_fields($post);
    558581    }
    559582    return $form_fields;
  • trunk/wp-admin/includes/schema.php

    r8600 r8612  
    259259    add_option('enable_xmlrpc', 0);
    260260
     261    // 2.7
     262    add_option('large_size_w', 1024);
     263    add_option('large_size_h', 1024);
     264
    261265    // Delete unused options
    262266    $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');
  • trunk/wp-admin/options-misc.php

    r7883 r8612  
    6363</fieldset></td>
    6464</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>
    6574</table>
    6675
  • trunk/wp-includes/media.php

    r8600 r8612  
    55// scale down the default size of an image so it's a better fit for the editor and theme
    66function image_constrain_size_for_editor($width, $height, $size = 'medium') {
     7    global $content_width;
    78
    89    if ( is_array($size) ) {
     
    2425        // if no width is set, default to the theme content width if available
    2526    }
    26     else { // $size == 'full'
    27         // 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
     27    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
    2829        // within the editor itself, and within the theme's content width if it's known.  the user can resize it in the editor
    2930        // 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    }
     36    // $size == 'full' has no constraint
     37    else {
     38        $max_width = $width;
     39        $max_height = $height;
    3540    }
    3641
    3742    list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size );
    38 
     43   
    3944    return wp_constrain_dimensions( $width, $height, $max_width, $max_height );
    4045}
     
    5257// Scale an image to fit a particular size (such as 'thumb' or 'medium'), and return an image URL, height and width.
    5358// 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
    5561function image_downsize($id, $size = 'medium') {
    5662
     
    6167    $meta = wp_get_attachment_metadata($id);
    6268    $width = $height = 0;
     69    $is_intermediate = false;
    6370
    6471    // plugins can use this to provide resize services
     
    7178        $width = $intermediate['width'];
    7279        $height = $intermediate['height'];
     80        $is_intermediate = true;
    7381    }
    7482    elseif ( $size == 'thumbnail' ) {
     
    7886            $width = $info[0];
    7987            $height = $info[1];
     88            $is_intermediate = true;
    8089        }
    8190    }
    8291    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 );
    85     }
    86 
    87     if ( $img_url)
    88         return array( $img_url, $width, $height );
     92        // any other type: use the real image
     93        $width = $meta['width'];
     94        $height = $meta['height'];
     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 );
     100
     101        return array( $img_url, $width, $height, $is_intermediate );
     102    }
    89103    return false;
    90104
  • trunk/wp-includes/version.php

    r8540 r8612  
    1616 * @global int $wp_db_version
    1717 */
    18 $wp_db_version = 8539;
     18$wp_db_version = 8585;
    1919
    2020?>
Note: See TracChangeset for help on using the changeset viewer.