Media: ensure JavaScript initialized when media edit screen is loaded directly.
Fix a JavaScript error when the media edit screen is loaded directly via a url such as `/wp-admin/post.php?post={post_id}&action=edit&image-editor`. Add a check in `imgLoaded` for `this.hold.sizer` which is set up during initialization and required for the cropping tool. Call `init` if this is undefined. Props NoseGraze. Fixes #38138. git-svn-id: https://develop.svn.wordpress.org/trunk@40020 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1a068f2a61
commit
856416049d
|
@ -573,6 +573,11 @@
|
||||||
imgLoaded : function(postid) {
|
imgLoaded : function(postid) {
|
||||||
var img = $('#image-preview-' + postid), parent = $('#imgedit-crop-' + postid);
|
var img = $('#image-preview-' + postid), parent = $('#imgedit-crop-' + postid);
|
||||||
|
|
||||||
|
// Ensure init has run even when directly loaded.
|
||||||
|
if ( 'undefined' === typeof this.hold.sizer ) {
|
||||||
|
this.init( postid );
|
||||||
|
}
|
||||||
|
|
||||||
this.initCrop(postid, img, parent);
|
this.initCrop(postid, img, parent);
|
||||||
this.setCropSelection(postid, 0);
|
this.setCropSelection(postid, 0);
|
||||||
this.toggleEditor(postid, 0);
|
this.toggleEditor(postid, 0);
|
||||||
|
|
Loading…
Reference in New Issue