Ticket #22597: 22597.4.diff

File 22597.4.diff, 2.3 KB (added by DH-Shredder, 6 months ago)

Also passes the mime_type for a more correct response, although this requires pulling the mime from the post.

Line 
1diff --git wp-admin/includes/image-edit.php wp-admin/includes/image-edit.php
2index 55d5902..5c3c851 100644
3--- wp-admin/includes/image-edit.php
4+++ wp-admin/includes/image-edit.php
5@@ -40,14 +40,14 @@ function wp_image_editor($post_id, $msg = false) {
6                <div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php
7 
8        // On some setups GD library does not provide imagerotate() - Ticket #11536
9-       if ( function_exists('imagerotate') ) { ?>
10+       if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { ?>
11                <div class="imgedit-rleft"  onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div>
12                <div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div>
13 <?php } else {
14-               $note_gdlib = esc_attr__('Image rotation is not supported by your web host (function imagerotate() is missing)');
15+               $note_no_rotate = esc_attr__('Image rotation is not supported by your web host.');
16 ?>
17-           <div class="imgedit-rleft disabled"  title="<?php echo $note_gdlib; ?>"></div>
18-           <div class="imgedit-rright disabled" title="<?php echo $note_gdlib; ?>"></div>
19+           <div class="imgedit-rleft disabled"  title="<?php echo $note_no_rotate; ?>"></div>
20+           <div class="imgedit-rright disabled" title="<?php echo $note_no_rotate; ?>"></div>
21 <?php } ?>
22 
23                <div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div>
24diff --git wp-includes/class-wp-image-editor-gd.php wp-includes/class-wp-image-editor-gd.php
25index 8a5d846..92dd287 100644
26--- wp-includes/class-wp-image-editor-gd.php
27+++ wp-includes/class-wp-image-editor-gd.php
28@@ -37,6 +37,14 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
29                if ( ! extension_loaded('gd') || ! function_exists('gd_info') )
30                        return false;
31 
32+               // On some setups GD library does not provide imagerotate() - Ticket #11536
33+               if ( isset( $args['methods'] ) &&
34+                        in_array( 'rotate', $args['methods'] ) &&
35+                        ! function_exists('imagerotate') ){
36+
37+                               return false;
38+               }
39+
40                return true;
41        }
42