Make WordPress Core


Ignore:
Timestamp:
02/21/2008 06:00:15 AM (18 years ago)
Author:
ryan
Message:

Image size options from tellyworth. fixes #5933

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r6943 r6952  
    132132    <label for="image-align-right" id="image-align-right-label"><?php _e('Right'); ?></label>
    133133</fieldset>
     134<fieldset id="image-size">
     135    <legend><?php _e('Size'); ?></legend>
     136    <input type="radio" name="image-size" id="image-size-thumb" value="thumb" <?php if ($image_size == 'thumb') echo ' checked="checked"'; ?>/>
     137    <label for="image-size-thumb" id="image-size-thumb-label"><?php _e('Thumbnail'); ?></label>
     138    <input type="radio" name="image-size" id="image-size-medium" value="medium" <?php if ($image_size == 'medium' || !$image_size) echo ' checked="checked"'; ?>/>
     139    <label for="image-size-medium" id="image-size-medium-label"><?php _e('Medium'); ?></label>
     140    <input type="radio" name="image-size" id="image-size-full" value="full" <?php if ($image_size == 'full') echo ' checked="checked"'; ?>/>
     141    <label for="image-size-full" id="image-size-full-label"><?php _e('Full size'); ?></label>
     142</fieldset>
    134143<p>
    135144    <button name="image-add" id="image-add" class="button-ok" value="1"><?php _e('Add Image'); ?></button>
     
    175184            wp_iframe( 'image_upload_form', get_option('siteurl') . '/wp-admin/media-upload.php?type=image', $_POST, $id );
    176185        else {
    177             media_send_to_editor(get_image_send_to_editor($id, $_POST['image-alt'], $_POST['image-title'], $_POST['image-align'], $_POST['image-url']));
     186            media_send_to_editor(get_image_send_to_editor($id, $_POST['image-alt'], $_POST['image-title'], $_POST['image-align'], $_POST['image-url'], true, $_POST['image-size']));
    178187        }
    179188    }
     
    218227add_filter('async_upload_image', 'async_image_callback');
    219228
    220 // scale down the default size of an image so it's a better fit for the editor and theme
    221 function image_constrain_size_for_editor($width, $height) {
    222     // pick a reasonable default width for the image
    223     // $content_width might be set in the theme's functions.php
    224     if ( !empty($GLOBALS['content_width']) )
    225         $max_width = $GLOBALS['content_width'];
    226     else
    227         $max_width = 500;
    228 
    229     $max_width = apply_filters( 'editor_max_image_width', $max_width );
    230     $max_height = apply_filters( 'editor_max_image_height', $max_width );
    231    
    232     return wp_shrink_dimensions( $width, $height, $max_width, $max_height );
    233 }
    234 
    235 function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false) {
    236 
    237     $img_src = wp_get_attachment_url($id);
    238     $meta = wp_get_attachment_metadata($id);
    239 
    240     $hwstring = '';
    241     if ( isset($meta['width'], $meta['height']) ) {
    242         list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'] );
    243         $hwstring = ' width="'.intval($width).'" height="'.intval($height).'"';
    244     }
    245 
    246     $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'"'.$hwstring.' class="align-'.attribute_escape($align).'" />';
     229
     230function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') {
     231
     232    $html = get_image_tag($id, $alt, $title, $align, $rel, $size);
    247233
    248234    $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : '';
    249235    if ( $url )
    250236        $html = "<a href='".attribute_escape($url)."'$rel>$html</a>";
     237    elseif ( $size == 'thumb' || $size == 'medium' )
     238        $html = '<a href="'.get_attachment_link($id).'"'.$rel.'>'.$html.'</a>';
    251239       
    252240    $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url );
     
    393381    $out = <<<EOF
    394382
    395 <a href="{$image_upload_iframe_src}&TB_iframe=true&height=500&width=480" class="thickbox"><img src='images/media-button-image.gif' alt='' /></a>
     383<a href="{$image_upload_iframe_src}&TB_iframe=true&height=550&width=480" class="thickbox"><img src='images/media-button-image.gif' alt='' /></a>
    396384<a href="{$multimedia_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox"><img src='images/media-button-gallery.gif' alt='' /></a>
    397385<a href="{$image_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox"><img src='images/media-button-video.gif' alt='' /></a>
Note: See TracChangeset for help on using the changeset viewer.