diff --git src/wp-admin/includes/image-edit.php src/wp-admin/includes/image-edit.php
index f8a9d50..97c888d 100644
|
|
function wp_image_editor($post_id, $msg = false) { |
131 | 131 | <p id="imgedit-save-target-<?php echo $post_id; ?>"> |
132 | 132 | <strong><?php _e('Apply changes to:'); ?></strong><br /> |
133 | 133 | |
134 | | <label class="imgedit-label"> |
135 | | <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" /> |
136 | | <?php _e('All image sizes'); ?></label> |
| 134 | <?php |
| 135 | $image_sizes = get_intermediate_image_sizes(); |
| 136 | $image_sizes[] = 'full'; |
| 137 | |
| 138 | /** This filter is documented in wp-admin/includes/media.php */ |
| 139 | $image_size_names = apply_filters( 'image_size_names_choose', array( |
| 140 | 'thumbnail' => __( 'Thumbnail' ), |
| 141 | 'medium' => __( 'Medium' ), |
| 142 | 'large' => __( 'Large' ), |
| 143 | 'post-thumbnail' => __( 'Featured Image' ), |
| 144 | 'full' => __( 'Full Size' ), |
| 145 | ) ); |
| 146 | |
| 147 | foreach ( $image_sizes as $image_size ) { |
| 148 | if ( ! isset( $image_size_names[ $image_size ] ) ) { |
| 149 | continue; |
| 150 | } |
| 151 | ?> |
| 152 | |
| 153 | <label class="imgedit-label"> |
| 154 | <input type="checkbox" name="imgedit-target-<?php echo $post_id; ?>" value="<?php echo esc_attr( $image_size ); ?>" checked="checked" /> |
| 155 | <?php echo esc_html( $image_size_names[ $image_size ] ); ?></label> |
137 | 156 | |
138 | | <label class="imgedit-label"> |
139 | | <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" /> |
140 | | <?php _e('Thumbnail'); ?></label> |
| 157 | <?php |
| 158 | } |
| 159 | ?> |
141 | 160 | |
142 | | <label class="imgedit-label"> |
143 | | <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" /> |
144 | | <?php _e('All sizes except thumbnail'); ?></label> |
145 | 161 | </p> |
146 | 162 | </div> |
147 | 163 | |
… |
… |
function wp_save_image( $post_id ) { |
655 | 671 | global $_wp_additional_image_sizes; |
656 | 672 | |
657 | 673 | $return = new stdClass; |
658 | | $success = $delete = $scaled = $nocrop = false; |
| 674 | $success = $scaled = false; |
659 | 675 | $post = get_post( $post_id ); |
660 | 676 | |
661 | 677 | $img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) ); |
… |
… |
function wp_save_image( $post_id ) { |
666 | 682 | |
667 | 683 | $fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0; |
668 | 684 | $fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0; |
669 | | $target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : ''; |
| 685 | $target = !empty($_REQUEST['target']) ? $_REQUEST['target'] : array(); |
670 | 686 | $scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do']; |
671 | 687 | |
| 688 | if ( ! is_array( $target ) ) { |
| 689 | $target = array( $target ); |
| 690 | } |
| 691 | |
| 692 | // Sanitize image sizes |
| 693 | foreach( $target as &$image_size ) { |
| 694 | $image_size = preg_replace( '/[^a-z0-9_-]+/i', '', $image_size ); |
| 695 | } |
| 696 | |
672 | 697 | if ( $scale && $fwidth > 0 && $fheight > 0 ) { |
673 | 698 | $size = $img->get_size(); |
674 | 699 | $sX = $size['width']; |
… |
… |
function wp_save_image( $post_id ) { |
715 | 740 | if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE && |
716 | 741 | isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) { |
717 | 742 | |
718 | | if ( 'thumbnail' == $target ) |
719 | | $new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}"; |
720 | | else |
721 | | $new_path = $path; |
| 743 | $new_path = $path; |
722 | 744 | } else { |
723 | 745 | while( true ) { |
724 | 746 | $filename = preg_replace( '/-e([0-9]+)$/', '', $filename ); |
… |
… |
function wp_save_image( $post_id ) { |
738 | 760 | return $return; |
739 | 761 | } |
740 | 762 | |
741 | | if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) { |
| 763 | if ( in_array( 'full', $target ) || $scaled ) { |
742 | 764 | $tag = false; |
743 | 765 | if ( isset($backup_sizes['full-orig']) ) { |
744 | 766 | if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) |
… |
… |
function wp_save_image( $post_id ) { |
758 | 780 | $meta['width'] = $size['width']; |
759 | 781 | $meta['height'] = $size['height']; |
760 | 782 | |
761 | | if ( $success && ('nothumb' == $target || 'all' == $target) ) { |
762 | | $sizes = get_intermediate_image_sizes(); |
763 | | if ( 'nothumb' == $target ) |
764 | | $sizes = array_diff( $sizes, array('thumbnail') ); |
765 | | } |
766 | | |
767 | 783 | $return->fw = $meta['width']; |
768 | 784 | $return->fh = $meta['height']; |
769 | | } elseif ( 'thumbnail' == $target ) { |
770 | | $sizes = array( 'thumbnail' ); |
771 | | $success = $delete = $nocrop = true; |
772 | 785 | } |
| 786 | else { |
| 787 | $success = true; |
| 788 | } |
| 789 | |
| 790 | /** |
| 791 | * Previously there were radio buttons under "Apply changes to:" |
| 792 | * and when you selected "Thumbnail", it would turn off cropping. |
| 793 | * We want to preserve this behaviour here for now. |
| 794 | */ |
| 795 | $nocrop = in_array( 'thumbnail', $target ) && 1 == count( $target ); |
| 796 | |
| 797 | if ( $success && ! $scaled ) { |
| 798 | $sizes = get_intermediate_image_sizes(); |
| 799 | // Excludes 'full' and any incorrect image sizes |
| 800 | $sizes = array_intersect( $sizes, $target ); |
773 | 801 | |
774 | | if ( isset( $sizes ) ) { |
775 | 802 | $_sizes = array(); |
776 | 803 | |
777 | 804 | foreach ( $sizes as $size ) { |
… |
… |
function wp_save_image( $post_id ) { |
810 | 837 | wp_update_attachment_metadata( $post_id, $meta ); |
811 | 838 | update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes); |
812 | 839 | |
813 | | if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) { |
| 840 | if ( ! $scaled ) { |
814 | 841 | // Check if it's an image edit from attachment edit screen |
815 | 842 | if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) { |
816 | 843 | $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true ); |
… |
… |
function wp_save_image( $post_id ) { |
824 | 851 | } |
825 | 852 | } |
826 | 853 | } |
827 | | } else { |
828 | | $delete = true; |
829 | 854 | } |
830 | 855 | |
831 | | if ( $delete ) { |
832 | | |
| 856 | if ( ! $success || ( ! $scaled && ! in_array( 'full', $target ) ) ) { |
833 | 857 | /** This filter is documented in wp-admin/custom-header.php */ |
834 | 858 | $delpath = apply_filters( 'wp_delete_file', $new_path ); |
835 | 859 | @unlink( $delpath ); |
diff --git src/wp-admin/js/image-edit.js src/wp-admin/js/image-edit.js
index 7bf2928..b8ae4a5 100644
|
|
var imageEdit = window.imageEdit = { |
68 | 68 | }, |
69 | 69 | |
70 | 70 | getTarget : function(postid) { |
71 | | return $('input[name="imgedit-target-' + postid + '"]:checked', '#imgedit-save-target-' + postid).val() || 'full'; |
| 71 | var target = new Array(); |
| 72 | $('input[name="imgedit-target-' + postid + '"]:checked', '#imgedit-save-target-' + postid).each(function() { |
| 73 | target.push(jQuery(this).val()); |
| 74 | }); |
| 75 | return target; |
72 | 76 | }, |
73 | 77 | |
74 | 78 | scaleChanged : function(postid, x) { |