diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 1c09443907..70125269f8 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -5594,10 +5594,14 @@ */ editAttachment: function( event ) { var editState = this.controller.state( 'edit-image' ); - event.preventDefault(); + if ( window.imageEdit ) { + event.preventDefault(); - editState.set( 'image', this.model ); - this.controller.setState( 'edit-image' ); + editState.set( 'image', this.model ); + this.controller.setState( 'edit-image' ); + } else { + this.$el.addClass('needs-refresh'); + } }, /** * @param {Object} event @@ -5944,10 +5948,12 @@ editAttachment: function( event ) { var editState = this.controller.state( 'edit-image' ); - event.preventDefault(); - editState.set( 'image', this.model.attachment ); - this.controller.setState( 'edit-image' ); + if ( window.imageEdit ) { + event.preventDefault(); + editState.set( 'image', this.model.attachment ); + this.controller.setState( 'edit-image' ); + } } }); diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 3201b8a61f..6fa1d550c1 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -666,7 +666,7 @@ function wp_print_media_templates() {
- <# if ( data.attachment ) { #> + <# if ( data.attachment && window.imageEdit ) { #> <# } #> diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 57f63118b4..a1afae1698 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -2536,6 +2536,9 @@ function wp_enqueue_media( $args = array() ) { wp_enqueue_script( 'media-editor' ); wp_enqueue_script( 'media-audiovideo' ); wp_enqueue_style( 'media-views' ); + if ( is_admin() ) { + wp_enqueue_script( 'image-edit' ); + } wp_enqueue_style( 'imgareaselect' ); wp_plupload_default_settings(); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 8319416909..ff2544ab59 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -394,7 +394,7 @@ function wp_default_scripts( &$scripts ) { // To enqueue media-views or media-editor, call wp_enqueue_media(). // Both rely on numerous settings, styles, and templates to operate correctly. - $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'image-edit' ), false, 1 ); + $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement' ), false, 1 ); $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor', 'mce-view' ), false, 1 ); $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models' ), false, 1 );