Make WordPress Core

Ticket #15668: 15668.diff

File 15668.diff, 5.8 KB (added by garyc40, 14 years ago)

based on alexkoti's suggested changes

  • wp-admin/css/media.dev.css

    diff --git wp-admin/css/media.dev.css wp-admin/css/media.dev.css
    index 66cd7e1..ad54b20 100644
    tr.image-size div.image-size-item { 
    7979        float: left;
    8080        width: 25%;
    8181        margin: 0;
     82        margin-bottom:6px;
    8283}
    8384
    8485#library-form .progress,
  • wp-admin/includes/media.php

    diff --git wp-admin/includes/media.php wp-admin/includes/media.php
    index c688b5e..dff8872 100644
    function image_align_input_fields( $post, $checked = '' ) { 
    845845 * @return unknown
    846846 */
    847847function image_size_input_fields( $post, $check = '' ) {
     848        global $_wp_additional_image_sizes;
     849       
     850        // get a list of the actual pixel dimensions of each possible intermediate version of this image
     851        $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'));
    848852
    849                 // get a list of the actual pixel dimensions of each possible intermediate version of this image
    850                 $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'));
    851 
    852                 if ( empty($check) )
    853                         $check = get_user_setting('imgsize', 'medium');
    854 
    855                 foreach ( $size_names as $size => $label ) {
    856                         $downsize = image_downsize($post->ID, $size);
    857                         $checked = '';
    858 
    859                         // is this size selectable?
    860                         $enabled = ( $downsize[3] || 'full' == $size );
    861                         $css_id = "image-size-{$size}-{$post->ID}";
    862                         // if this size is the default but that's not available, don't select it
    863                         if ( $size == $check ) {
    864                                 if ( $enabled )
    865                                         $checked = " checked='checked'";
    866                                 else
    867                                         $check = '';
    868                         } elseif ( !$check && $enabled && 'thumbnail' != $size ) {
    869                                 // if $check is not enabled, default to the first available size that's bigger than a thumbnail
    870                                 $check = $size;
    871                                 $checked = " checked='checked'";
    872                         }
     853        foreach( $_wp_additional_image_sizes as $size_name => $size_name_attr ){
     854                $size_names[$size_name] = __($size_name_attr['label']);
     855        }
     856       
     857        $size_names = apply_filters( 'image_size_names', $size_names );
     858
     859        if ( empty($check) )
     860                $check = get_user_setting('imgsize', 'medium');
    873861
    874                         $html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
     862        foreach ( $size_names as $size => $label ) {
     863                $downsize = image_downsize($post->ID, $size);
     864                $checked = '';
    875865
    876                         $html .= "<label for='{$css_id}'>$label</label>";
    877                         // only show the dimensions if that choice is available
     866                // is this size selectable?
     867                $enabled = ( $downsize[3] || 'full' == $size );
     868                $css_id = "image-size-{$size}-{$post->ID}";
     869                // if this size is the default but that's not available, don't select it
     870                if ( $size == $check ) {
    878871                        if ( $enabled )
    879                                 $html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2] ). "</label>";
     872                                $checked = " checked='checked'";
     873                        else
     874                                $check = '';
     875                } elseif ( !$check && $enabled && 'thumbnail' != $size ) {
     876                        // if $check is not enabled, default to the first available size that's bigger than a thumbnail
     877                        $check = $size;
     878                        $checked = " checked='checked'";
     879                }
    880880
    881                         $html .= '</div>';
     881                $html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
    882882
    883                         $out[] = $html;
    884                 }
     883                $html .= "<label for='{$css_id}'>$label</label>";
     884                // only show the dimensions if that choice is available
     885                if ( $enabled )
     886                        $html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2] ). "</label>";
    885887
    886                 return array(
    887                         'label' => __('Size'),
    888                         'input' => 'html',
    889                         'html'  => join("\n", $out),
    890                 );
     888                $html .= '</div>';
     889
     890                $out[] = $html;
     891        }
     892
     893        return array(
     894                'label' => __('Size'),
     895                'input' => 'html',
     896                'html'  => join("\n", $out),
     897        );
    891898}
    892899
    893900/**
  • wp-content/themes/twentyten/functions.php

    diff --git wp-content/themes/twentyten/functions.php wp-content/themes/twentyten/functions.php
    index 3f236c9..7bf6f2a 100644
    function twentyten_setup() { 
    119119        // We'll be using post thumbnails for custom header images on posts and pages.
    120120        // We want them to be 940 pixels wide by 198 pixels tall.
    121121        // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
    122         set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
     122        set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true, __( 'Post Thumbnail' ) );
    123123
    124124        // Don't support text inside the header image.
    125125        if ( ! defined( 'NO_HEADER_TEXT' ) )
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index 041c4e5..8f7ba23 100644
    function image_downsize($id, $size = 'medium') { 
    178178/**
    179179 * Registers a new image size
    180180 */
    181 function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {
     181function add_image_size( $name, $width = 0, $height = 0, $crop = false, $label = false ) {
    182182        global $_wp_additional_image_sizes;
    183         $_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => (bool) $crop );
     183        if ( ! $label )
     184                $label = $name;
     185        $_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => (bool) $crop, 'label' => $label );
    184186}
    185187
    186188/**
    187189 * Registers an image size for the post thumbnail
    188190 */
    189 function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
    190         add_image_size( 'post-thumbnail', $width, $height, $crop );
     191function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false, $label = false ) {
     192        add_image_size( 'post-thumbnail', $width, $height, $crop, $label );
    191193}
    192194
    193195/**