Ticket #30155: 30155.4.diff
File 30155.4.diff, 3.4 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/image-edit.php
diff --git src/wp-admin/includes/image-edit.php src/wp-admin/includes/image-edit.php index d9cf6048f2..49cb370d3e 100644
function wp_image_editor($post_id, $msg = false) { 182 182 <div class="imgedit-panel-content wp-clearfix"> 183 183 <?php echo $note; ?> 184 184 <div class="imgedit-menu wp-clearfix"> 185 <button type="button" onclick="imageEdit. crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Crop' ); ?></span></button><?php185 <button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this )" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Crop' ); ?></span></button><?php 186 186 187 187 // On some setups GD library does not provide imagerotate() - Ticket #11536 188 188 if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { -
src/wp-admin/js/image-edit.js
diff --git src/wp-admin/js/image-edit.js src/wp-admin/js/image-edit.js index 0d8eaf081f..ae2b8d950a 100644
19 19 _view : false, 20 20 21 21 /** 22 * Handle crop tool clicks. 23 */ 24 handleCropToolClick: function( postid, nonce, cropButton ) { 25 var img = $( '#image-preview-' + postid ), 26 selection = this.iasapi.getSelection(); 27 28 // Ensure selection is available, otherwise reset to full image. 29 if ( isNaN( selection.x1 ) ) { 30 this.setCropSelection( postid, { 'x1': 0, 'y1': 0, 'x2': img.innerWidth(), 'y2': img.innerHeight(), 'width': img.innerWidth(), 'height': img.innerHeight() } ); 31 selection = this.iasapi.getSelection(); 32 } 33 34 // If we don't already have a selection, select the entire image. 35 if ( 0 === selection.x1 && 0 === selection.y1 && 0 === selection.x2 && 0 === selection.y2 ) { 36 this.iasapi.setSelection( 0, 0, img.innerWidth(), img.innerHeight(), true ); 37 this.iasapi.setOptions( { show: true } ); 38 this.iasapi.update(); 39 } else { 40 41 // Otherwise, perform the crop. 42 imageEdit.crop( postid, nonce , cropButton ); 43 } 44 }, 45 46 /** 22 47 * @summary Converts a value to an integer. 23 48 * 24 49 * @memberof imageEdit … … 351 376 t.hold.sizer = max1 > max2 ? max2 / max1 : 1; 352 377 353 378 t.initCrop(postid, img, parent); 354 t.setCropSelection(postid, 0);355 379 356 380 if ( (typeof callback !== 'undefined') && callback !== null ) { 357 381 callback(); … … 579 603 } 580 604 581 605 this.initCrop(postid, img, parent); 582 this.setCropSelection(postid, 0); 606 this.setCropSelection( postid, { 'x1': 0, 'y1': 0, 'x2': 0, 'y2': 0, 'width': img.innerWidth(), 'height': img.innerHeight() } ); 607 583 608 this.toggleEditor(postid, 0); 584 609 // Editor is ready, move focus to the first focusable element. 585 610 $( '.imgedit-wrap .imgedit-help-toggle' ).eq( 0 ).focus(); … … 695 720 c = c || 0; 696 721 697 722 if ( !c || ( c.width < 3 && c.height < 3 ) ) { 698 this.setDisabled( $('.imgedit-crop', '#imgedit-panel-' + postid), 0);699 this.setDisabled( $('#imgedit-crop-sel-' + postid), 0);723 this.setDisabled( $( '.imgedit-crop', '#imgedit-panel-' + postid ), 1 ); 724 this.setDisabled( $( '#imgedit-crop-sel-' + postid ), 1 ); 700 725 $('#imgedit-sel-width-' + postid).val(''); 701 726 $('#imgedit-sel-height-' + postid).val(''); 702 727 $('#imgedit-selection-' + postid).val('');