Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.