[wp-trac] [WordPress Trac] #15668: Add additional image sizes to thickbox

WordPress Trac wp-trac at lists.automattic.com
Fri Dec 3 20:05:06 UTC 2010


#15668: Add additional image sizes to thickbox
-------------------------+--------------------------------------------------
 Reporter:  alexkoti     |       Owner:                 
     Type:  enhancement  |      Status:  new            
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Media        |     Version:  3.1            
 Severity:  minor        |    Keywords:                 
-------------------------+--------------------------------------------------
 Automatically add additional image sizes to thickbox, and provide a hook
 to filter sizes, in wp-admin/includes/media.php

 {{{
 function image_size_input_fields( $post, $check = '' ) {

                 // get a list of the actual pixel dimensions of each
 possible intermediate version of this image
                 $size_names = array('thumbnail' => __('Thumbnail'),
 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full
 Size'));

                 global $_wp_additional_image_sizes;
                 foreach($_wp_additional_image_sizes as $size_name =>
 $size_name_attr){
                         $size_names[$size_name] =
 __($size_name_attr['label']);
                 }
                 $size_names = apply_filters('image_size_names',
 $size_names);

                 if ( empty($check) )
                         $check = get_user_setting('imgsize', 'medium');

 }}}

 Add $label to add_image_size() and set_post_thumbnail_size(), in wp-
 includes/media.php

 {{{
 /**
  * Registers a new image size
  */
 function add_image_size( $name, $width = 0, $height = 0, $crop = FALSE,
 $label = FALSE ) {
         global $_wp_additional_image_sizes;
         if( empty($label) )
                 $label = $name;
         $_wp_additional_image_sizes[$name] = array( 'width' => absint(
 $width ), 'height' => absint( $height ), 'crop' => !!$crop, 'label' =>
 $label );
 }

 /**
  * Registers an image size for the post thumbnail
  */
 function set_post_thumbnail_size( $width = 0, $height = 0, $crop = FALSE,
 $label = FALSE ) {
         add_image_size( 'post-thumbnail', $width, $height, $crop, $label
 );
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15668>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list