diff --git wp-admin/includes/image-edit.php wp-admin/includes/image-edit.php
index 55d5902..a7d6075 100644
|
|
|
function wp_image_editor($post_id, $msg = false) { |
| 40 | 40 | <div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php |
| 41 | 41 | |
| 42 | 42 | // On some setups GD library does not provide imagerotate() - Ticket #11536 |
| 43 | | if ( function_exists('imagerotate') ) { ?> |
| | 43 | if ( wp_image_editor_supports( array( 'methods', array( 'rotate' ) ) ) ) { ?> |
| 44 | 44 | <div class="imgedit-rleft" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div> |
| 45 | 45 | <div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div> |
| 46 | 46 | <?php } else { |
| 47 | | $note_gdlib = esc_attr__('Image rotation is not supported by your web host (function imagerotate() is missing)'); |
| | 47 | $note_no_rotate = esc_attr__('Image rotation is not supported by your web host.'); |
| 48 | 48 | ?> |
| 49 | | <div class="imgedit-rleft disabled" title="<?php echo $note_gdlib; ?>"></div> |
| 50 | | <div class="imgedit-rright disabled" title="<?php echo $note_gdlib; ?>"></div> |
| | 49 | <div class="imgedit-rleft disabled" title="<?php echo $note_no_rotate; ?>"></div> |
| | 50 | <div class="imgedit-rright disabled" title="<?php echo $note_no_rotate; ?>"></div> |
| 51 | 51 | <?php } ?> |
| 52 | 52 | |
| 53 | 53 | <div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div> |
diff --git wp-includes/class-wp-image-editor-gd.php wp-includes/class-wp-image-editor-gd.php
index 8a5d846..92dd287 100644
|
|
|
class WP_Image_Editor_GD extends WP_Image_Editor { |
| 37 | 37 | if ( ! extension_loaded('gd') || ! function_exists('gd_info') ) |
| 38 | 38 | return false; |
| 39 | 39 | |
| | 40 | // On some setups GD library does not provide imagerotate() - Ticket #11536 |
| | 41 | if ( isset( $args['methods'] ) && |
| | 42 | in_array( 'rotate', $args['methods'] ) && |
| | 43 | ! function_exists('imagerotate') ){ |
| | 44 | |
| | 45 | return false; |
| | 46 | } |
| | 47 | |
| 40 | 48 | return true; |
| 41 | 49 | } |
| 42 | 50 | |
diff --git wp-includes/class-wp-image-editor-imagick.php wp-includes/class-wp-image-editor-imagick.php
index ad07ae2..d29fefd 100644
|
|
|
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
| 38 | 38 | * @return boolean |
| 39 | 39 | */ |
| 40 | 40 | public static function test( $args = array() ) { |
| 41 | | if ( ! extension_loaded( 'imagick' ) || ! is_callable( 'Imagick', 'queryFormats' ) ) |
| | 41 | |
| | 42 | $required_methods = array( |
| | 43 | 'clear', |
| | 44 | 'destroy', |
| | 45 | 'valid', |
| | 46 | 'getimage', |
| | 47 | 'writeimage', |
| | 48 | 'getimageblob', |
| | 49 | 'getimagegeometry', |
| | 50 | 'getimageformat', |
| | 51 | 'setimageformat', |
| | 52 | 'setimagecompression', |
| | 53 | 'setimagecompressionquality', |
| | 54 | 'setimagepage', |
| | 55 | 'scaleimage', |
| | 56 | 'cropimage', |
| | 57 | 'rotateimage', |
| | 58 | 'flipimage', |
| | 59 | 'flopimage', |
| | 60 | ); |
| | 61 | |
| | 62 | // Check for requirements |
| | 63 | if ( ! extension_loaded( 'imagick' ) || |
| | 64 | ! class_exists( 'Imagick' ) || |
| | 65 | ! is_callable( 'Imagick', 'queryFormats' ) || |
| | 66 | ! class_exists( 'ImagickPixel' ) || |
| | 67 | ! defined( 'imagick::COMPRESSION_JPEG' ) || |
| | 68 | array_diff( $required_methods, get_class_methods( 'Imagick' ) ) ) { |
| | 69 | |
| | 70 | return false; |
| | 71 | } |
| | 72 | |
| | 73 | /** |
| | 74 | * setIteratorIndex is optional unless mime is an animated format. |
| | 75 | * Here, we just say no if a user is attempting to |
| | 76 | * edit a GIF and setIteratorIndex isn't available. |
| | 77 | */ |
| | 78 | if ( ( ! isset( $args['mime_type'] ) || $args['mime_type'] == 'image/gif' ) && |
| | 79 | ! method_exists( 'Imagick', 'setIteratorIndex' ) ) { |
| | 80 | |
| 42 | 81 | return false; |
| | 82 | } |
| 43 | 83 | |
| 44 | 84 | return true; |
| 45 | 85 | } |
| … |
… |
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
| 88 | 128 | if( ! $this->image->valid() ) |
| 89 | 129 | return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file); |
| 90 | 130 | |
| 91 | | // Select the first frame to handle animated GIFs properly |
| 92 | | $this->image->setIteratorIndex(0); |
| | 131 | // Select the first frame to handle animated images properly |
| | 132 | if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) |
| | 133 | $this->image->setIteratorIndex(0); |
| | 134 | |
| 93 | 135 | $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() ); |
| 94 | 136 | } |
| 95 | 137 | catch ( Exception $e ) { |