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.

Built from https://develop.svn.wordpress.org/trunk@40020


git-svn-id: http://core.svn.wordpress.org/trunk@39957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2017-01-27 18:30:43 +00:00
parent 69c29935d5
commit a6d772108d
3 changed files with 7 additions and 2 deletions

View File

@ -573,6 +573,11 @@
imgLoaded : function(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.setCropSelection(postid, 0);
this.toggleEditor(postid, 0);

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40019';
$wp_version = '4.8-alpha-40020';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.