Make WordPress Core

Ticket #28277: image-edit.diff

File image-edit.diff, 2.0 KB (added by silb3r, 12 years ago)

Add ability to apply image edits to custom image sizes only

  • src/wp-admin/includes/image-edit.php

     
    3232                        $note = "<div class='updated'><p>$msg->msg</p></div>";
    3333        }
    3434
     35        $edit_custom_sizes = apply_filters('edit_custom_thumbnail_sizes', false);
     36
    3537        ?>
    3638        <div class="imgedit-wrap">
    3739        <div id="imgedit-panel-<?php echo $post_id; ?>">
     
    138140                <label class="imgedit-label">
    139141                <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
    140142                <?php _e('All sizes except thumbnail'); ?></label>
     143
     144                <?php if($edit_custom_sizes) : ?>
     145                        <?php foreach(array_unique($edit_custom_sizes) as $label => $size) : ?>
     146                                <?php if(array_key_exists($size, $meta['sizes'])) : ?>
     147                                        <label class="imgedit-label">
     148                                        <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="<?php _e($size); ?>" />
     149                                        <?php _e($label); ?></label>
     150                                <?php endif; ?>
     151                        <?php endforeach; ?>
     152                <?php endif; ?>
     153
    141154        </p>
    142155        </div>
    143156
     
    745758                $meta['width'] = $size['width'];
    746759                $meta['height'] = $size['height'];
    747760
    748                 if ( $success && ('nothumb' == $target || 'all' == $target) ) {
     761                if ( $success ) {
    749762                        $sizes = get_intermediate_image_sizes();
    750                         if ( 'nothumb' == $target )
    751                                 $sizes = array_diff( $sizes, array('thumbnail') );
     763                        if ( 'nothumb' == $target || 'all' == $target ) {
     764                                if ( 'nothumb' == $target )
     765                                        $sizes = array_diff( $sizes, array('thumbnail') );
     766                        } elseif ( 'thumbnail' !== $target ) {
     767                                $sizes = array_diff( $sizes, array($target) );
     768                        }
    752769                }
    753770
    754771                $return->fw = $meta['width'];
     
    756773        } elseif ( 'thumbnail' == $target ) {
    757774                $sizes = array( 'thumbnail' );
    758775                $success = $delete = $nocrop = true;
     776        } else {
     777                $sizes = array( $target );
     778                $success = $delete = true;
     779                $nocrop = $_wp_additional_image_sizes[ $size ]['crop'];
    759780        }
    760781
    761782        if ( isset( $sizes ) ) {