Make WordPress Core

Ticket #11895: image-edit.patch

File image-edit.patch, 4.5 KB (added by frankgroeneveld, 15 years ago)
  • wp-admin/includes/image-edit.php

     
    173173                <strong><?php _e('Apply changes to:'); ?></strong><br />
    174174
    175175                <label class="imgedit-label">
    176                 <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
    177                 <?php _e('All image sizes'); ?></label>
     176                <input type="checkbox" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" checked="checked" />
     177                <?php _e('Thumbnail'); ?></label>
    178178
    179179                <label class="imgedit-label">
    180                 <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
    181                 <?php _e('Thumbnail'); ?></label>
     180                <input type="checkbox" name="imgedit-target-<?php echo $post_id; ?>" value="medium" checked="checked" />
     181                <?php _e('Medium'); ?></label>
    182182
    183183                <label class="imgedit-label">
    184                 <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
    185                 <?php _e('All sizes except thumbnail'); ?></label>
     184                <input type="checkbox" name="imgedit-target-<?php echo $post_id; ?>" value="large" checked="checked" />
     185                <?php _e('Large'); ?></label>
     186
     187                <label class="imgedit-label">
     188                <input type="checkbox" name="imgedit-target-<?php echo $post_id; ?>" value="full" checked="checked" />
     189                <?php _e('Full size'); ?></label>
    186190        </p>
    187191        </div>
    188192
     
    505509
    506510        $fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0;
    507511        $fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0;
    508         $target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
     512        $target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : array();
    509513        $scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do'];
    510514
    511515        if ( $scale && $fwidth > 0 && $fheight > 0 ) {
     
    557561        if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
    558562                isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) {
    559563
    560                 if ( 'thumbnail' == $target )
     564                if ( in_array('thumbnail', $target) )
    561565                        $new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}";
    562566                else
    563567                        $new_path = $path;
     
    580584                return $return;
    581585        }
    582586
    583         if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) {
     587        if ( in_array('full', $target) || $scaled ) {
    584588                $tag = false;
    585589                if ( isset($backup_sizes['full-orig']) ) {
    586590                        if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] )
     
    601605                list ( $uwidth, $uheight ) = wp_shrink_dimensions($meta['width'], $meta['height']);
    602606                $meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
    603607
    604                 if ( $success && ('nothumb' == $target || 'all' == $target) ) {
    605                         $sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
    606                         if ( 'nothumb' == $target )
    607                                 $sizes = array_diff( $sizes, array('thumbnail') );
     608                if ( $success ) {
     609                        $sizes = $target;
    608610                }
    609611
    610612                $return->fw = $meta['width'];
    611613                $return->fh = $meta['height'];
    612         } elseif ( 'thumbnail' == $target ) {
    613                 $sizes = array( 'thumbnail' );
     614        } else {
     615                $sizes = $target;
    614616                $success = $delete = $nocrop = true;
    615617        }
    616618
     
    643645                wp_update_attachment_metadata($post_id, $meta);
    644646                update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
    645647
    646                 if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
     648                if ( in_array('thumbnail', $target) || sizeof($target) == 4 || in_array('full', $target) ) {
    647649                        $file_url = wp_get_attachment_url($post_id);
    648650                        if ( $thumb = $meta['sizes']['thumbnail'] )
    649651                                $return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
  • wp-admin/js/image-edit.dev.js

     
    6464        },
    6565
    6666        getTarget : function(postid) {
    67                 return $('input[name=imgedit-target-' + postid + ']:checked', '#imgedit-save-target-' + postid).val() || 'full';
     67                var target = new Array();
     68                $('input[name=imgedit-target-' + postid + ']:checked').each(function() {
     69                                target.push(jQuery(this).val());
     70                });
     71                return target;
    6872        },
    6973
    7074        scaleChanged : function(postid, x) {
     
    241245                        '_ajax_nonce': nonce,
    242246                        'postid': postid,
    243247                        'history': history,
    244                         'target': target,
     248                        'target[]': target,
    245249                        'do': 'save'
    246250                };
    247251