WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#22597 closed defect (bug) (fixed)

Image Editor checking GD directly for rotate support

Reported by: mikeschroder Owned by: ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: has-patch commit
Focuses: Cc:

Description

The image editor is currently checking imagerotate() directly to decide whether it should enable the rotate buttons.

We should be checking the image editor.

The initial patch is a bit creative because we assume rotate() is a required function with the WP_Image_Editor class.

Attachments (4)

22597.diff (4.4 KB) - added by mikeschroder 4 years ago.
22597.2.diff (2.3 KB) - added by mikeschroder 4 years ago.
22597.3.diff (2.3 KB) - added by mikeschroder 4 years ago.
22597.4.diff (2.3 KB) - added by mikeschroder 4 years ago.
Also passes the mime_type for a more correct response, although this requires pulling the mime from the post.

Download all attachments as: .zip

Change History (12)

@mikeschroder
4 years ago

@mikeschroder
4 years ago

#1 @mikeschroder
4 years ago

Got some extra stuff accidentally in initial patch.
22597.2.diff is the proper one.

#2 @markoheijnen
4 years ago

  • Milestone changed from Awaiting Review to 3.5

#3 @scribu
4 years ago

  • Cc scribu added

#4 @nacin
4 years ago

array( 'methods', array( 'rotate' ) ) — this should be 'methods' => array( 'rotate' ), I imagine?

@mikeschroder
4 years ago

#5 @mikeschroder
4 years ago

Yes, yes it should have been, thanks.
Now it is, and has been further/better tested.

@mikeschroder
4 years ago

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

#6 @mikeschroder
4 years ago

As a second option, 22597.4.diff​ also passes mime_type through to check for support.

This requires pulling the mime from the post, though.

It is more accurate, however, since you could get in a situation where rotate() is supported by an editor, but the mime type is not (for instance, in the case of a GD install that is sadly lacking of imagerotate() along with a really old Imagick install lacking setIteratorIndex() when trying to rotate a GIF.

Related: #22543

#7 @nacin
4 years ago

  • Keywords commit added

I'm game for 22597.4.diff.

#8 @ryan
4 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In 22863:

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

Note: See TracTickets for help on using tickets.