Only enqueue the image editor in the media modal in the admin.

props gcorne.
see #21811.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-03-19 21:16:14 +00:00
parent 4aacf01403
commit 30fd56b3dc
5 changed files with 18 additions and 9 deletions

View File

@ -5594,10 +5594,14 @@
*/
editAttachment: function( event ) {
var editState = this.controller.state( 'edit-image' );
if ( window.imageEdit ) {
event.preventDefault();
editState.set( 'image', this.model );
this.controller.setState( 'edit-image' );
} else {
this.$el.addClass('needs-refresh');
}
},
/**
* @param {Object} event
@ -5944,11 +5948,13 @@
editAttachment: function( event ) {
var editState = this.controller.state( 'edit-image' );
event.preventDefault();
if ( window.imageEdit ) {
event.preventDefault();
editState.set( 'image', this.model.attachment );
this.controller.setState( 'edit-image' );
}
}
});
/**

File diff suppressed because one or more lines are too long

View File

@ -666,7 +666,7 @@ function wp_print_media_templates() {
<div class="thumbnail">
<img src="{{ data.model.url }}" draggable="false" />
</div>
<# if ( data.attachment ) { #>
<# if ( data.attachment && window.imageEdit ) { #>
<input type="button" class="edit-attachment button" value="<?php esc_attr_e( 'Edit Image' ); ?>" />
<# } #>

View File

@ -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();

View File

@ -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 );