Make WordPress Core

Opened 8 years ago

Closed 5 years ago

#38192 closed defect (bug) (worksforme)

Linking directly into Edit Image mode breaks cropping; imageEdit.init not triggered.

Reported by: dougwollison's profile dougwollison Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6.1
Component: Media Keywords: has-patch needs-testing
Focuses: Cc:

Description

I've noticed for a while that when jumping directly into Edit Image mode on an attachment (namely when clicking the "Edit Image" link for an attachment inside the Media Manager), trying to crop the image doesn't work.

To reproduce, simply visit the edit link for any attachment with "&image-editor" tacked onto the URL. (e.g. /wp-admin/post.php?post=123&action=edit&image-editor)

When you drag to create the crop box, the Selection values keep saying NaN, and so trying to confirm your selection won't do anything, not even give you a visible error.

Currently, the only solution when when this occurs is to click cancel, then the Edit Image button on the screen there, where it properly initializes.

After some debugging in wp-admin/js/image-edit.js, I found the cause was that imageEdit.hold.sizer was undefined, which is set by imageEdit.init(). This method is called when the Edit Image button is clicked manually, but it never get's called on page load when it's triggered automatically.

Not entirely sure where the call should go, but that should be the only adjustment needed to make it work.

Attachments (1)

image-edit.php.diff (1.5 KB) - added by jbotte 8 years ago.
diff for image-edit.php to trigger imageEdit.init() if linking directly to the image editor.

Download all attachments as: .zip

Change History (7)

#1 @jbotte
8 years ago

Working on a patch, still going down the rabbit hole. Will try and post something next week.

@jbotte
8 years ago

diff for image-edit.php to trigger imageEdit.init() if linking directly to the image editor.

#2 @jbotte
8 years ago

  • Keywords has-patch needs-testing added

I attached a small patch above. First patch so if things aren't up to snuff I appreciate feedback to help improve.

On php page load i check for the 'image-editor' key in the $_GET array.

If the key exists I populate $image_edit_additional_js with the JS that will trigger imageEdit.init();

I then echo that js in the image-preview onload.

Let me know if you have any questions. Please test!

hope this helps you @dougwollison

#3 @jbotte
8 years ago

  • Component changed from Editor to Media

#4 @desrosj
6 years ago

  • Keywords close added

Thanks for all your work on this, @jbotte! Sorry that this did not receive a response sooner.

I have been working to reproduce this issue, but I have not yet been able to on WordPress 5.1.1. @jbotte or @dougwollison, are you able to provide more information to reproduce the error?

I am thinking this may have been fixed in another ticket (maybe with [42404], @adamsilverstein). Going to mark as close unless someone else can reproduce this.

#5 @dougwollison
6 years ago

Pretty sure it's been solved. The flow to recreate the issue was:

  1. Open media library modal while editing a page
  2. Select the image you want to edit
  3. Click the Edit Image link in the sidebar

It would open the attachment editor in a new page and that's where the issue would occur. I just tested it and it appears to be fixed, not sure how long ago though.

I oddly don't recall ever getting notifications about @jbotte's activity on this, I would've responded in if so.

#6 @desrosj
5 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Thanks, @dougwollison! Closing out.

Note: See TracTickets for help on using tickets.