In wp_image_editor(), use wp_image_editor_supports() to check for rotation capabilities rather than directly checking the existence of the imagerotate function.

In WP_Image_Editor_GD::test(), check for existence of imagerotate if the rotate capability is required.

Props DH-Shredder
fixes #22597


git-svn-id: http://core.svn.wordpress.org/trunk@22863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-11-27 14:36:55 +00:00
parent 3287c609a1
commit d4159bf041
2 changed files with 12 additions and 4 deletions

View File

@ -40,14 +40,14 @@ function wp_image_editor($post_id, $msg = false) {
<div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php
// On some setups GD library does not provide imagerotate() - Ticket #11536
if ( function_exists('imagerotate') ) { ?>
if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { ?>
<div class="imgedit-rleft" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div>
<div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div>
<?php } else {
$note_gdlib = esc_attr__('Image rotation is not supported by your web host (function imagerotate() is missing)');
$note_no_rotate = esc_attr__('Image rotation is not supported by your web host.');
?>
<div class="imgedit-rleft disabled" title="<?php echo $note_gdlib; ?>"></div>
<div class="imgedit-rright disabled" title="<?php echo $note_gdlib; ?>"></div>
<div class="imgedit-rleft disabled" title="<?php echo $note_no_rotate; ?>"></div>
<div class="imgedit-rright disabled" title="<?php echo $note_no_rotate; ?>"></div>
<?php } ?>
<div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div>

View File

@ -37,6 +37,14 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
if ( ! extension_loaded('gd') || ! function_exists('gd_info') )
return false;
// On some setups GD library does not provide imagerotate() - Ticket #11536
if ( isset( $args['methods'] ) &&
in_array( 'rotate', $args['methods'] ) &&
! function_exists('imagerotate') ){
return false;
}
return true;
}