When editing a gallery, images can now be added from the media library.
Enables the "Add images from media library" button when editing. The UX has room for improvement, but it's a start. see #21390, #21809. git-svn-id: https://develop.svn.wordpress.org/trunk@22157 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a04930b340
commit
04143f286a
|
@ -42,11 +42,16 @@
|
||||||
// then unset the property.
|
// then unset the property.
|
||||||
this.add( 'library', media.view.Workspace.Library, {
|
this.add( 'library', media.view.Workspace.Library, {
|
||||||
collection: media.query( this.get('library') )
|
collection: media.query( this.get('library') )
|
||||||
} );
|
});
|
||||||
this.unset('library');
|
this.unset('library');
|
||||||
|
|
||||||
// Add the gallery view.
|
// Add the gallery view.
|
||||||
this.add( 'gallery', media.view.Workspace.Gallery, { collection: this.selection } );
|
this.add( 'gallery', media.view.Workspace.Gallery, {
|
||||||
|
collection: this.selection
|
||||||
|
});
|
||||||
|
this.add( 'gallery-library', media.view.Workspace.Library.Gallery, {
|
||||||
|
collection: media.query({ type: 'image' })
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -719,6 +724,38 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
media.view.Workspace.Library.Gallery = media.view.Workspace.Library.extend({
|
||||||
|
initToolbarView: function() {
|
||||||
|
var controller = this.controller,
|
||||||
|
editing = controller.get('editing'),
|
||||||
|
items = {
|
||||||
|
'selection-preview': new media.view.SelectionPreview({
|
||||||
|
controller: this.controller,
|
||||||
|
collection: this.controller.selection,
|
||||||
|
priority: -40,
|
||||||
|
clearable: false
|
||||||
|
}),
|
||||||
|
|
||||||
|
'continue-editing-gallery': {
|
||||||
|
style: 'primary',
|
||||||
|
text: l10n.continueEditingGallery,
|
||||||
|
priority: 40,
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
controller.render( 'gallery' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.toolbarView = new media.view.Toolbar({
|
||||||
|
items: items
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$el.addClass('with-toolbar');
|
||||||
|
this.$content.append( this.toolbarView.$el );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wp.media.view.Workspace.Gallery
|
* wp.media.view.Workspace.Gallery
|
||||||
*/
|
*/
|
||||||
|
@ -750,23 +787,16 @@
|
||||||
click: _.bind( controller.update, controller, 'gallery' )
|
click: _.bind( controller.update, controller, 'gallery' )
|
||||||
},
|
},
|
||||||
|
|
||||||
'add-images-from-library': {
|
'return-to-library': {
|
||||||
text: l10n.addImagesFromLibrary,
|
text: editing ? l10n.addImagesFromLibrary : l10n.returnToLibrary,
|
||||||
priority: 30
|
priority: -40,
|
||||||
|
|
||||||
|
click: function() {
|
||||||
|
controller.render( editing ? 'gallery-library' : 'library' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( ! editing ) {
|
|
||||||
items['return-to-library'] = {
|
|
||||||
text: l10n.returnToLibrary,
|
|
||||||
priority: -40,
|
|
||||||
|
|
||||||
click: function() {
|
|
||||||
controller.render('library');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.toolbarView = new media.view.Toolbar({
|
this.toolbarView = new media.view.Toolbar({
|
||||||
items: items
|
items: items
|
||||||
});
|
});
|
||||||
|
@ -948,13 +978,17 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
_.defaults( this.options, {
|
||||||
|
clearable: true
|
||||||
|
});
|
||||||
|
|
||||||
this.controller = this.options.controller;
|
this.controller = this.options.controller;
|
||||||
this.collection.on( 'add change:url remove', this.render, this );
|
this.collection.on( 'add change:url remove', this.render, this );
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var options = {},
|
var options = _.clone( this.options ),
|
||||||
first, sizes, amount;
|
first, sizes, amount;
|
||||||
|
|
||||||
// If nothing is selected, display nothing.
|
// If nothing is selected, display nothing.
|
||||||
|
|
|
@ -1358,7 +1358,9 @@ function wp_print_media_templates( $attachment ) {
|
||||||
|
|
||||||
<span class="count"><%- count %></span>
|
<span class="count"><%- count %></span>
|
||||||
</div>
|
</div>
|
||||||
<a class="clear-selection" href="#"><?php _e('Clear selection'); ?></a>
|
<% if ( clearable ) { %>
|
||||||
|
<a class="clear-selection" href="#"><?php _e('Clear selection'); ?></a>
|
||||||
|
<% } %>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="tmpl-editor-attachment">
|
<script type="text/html" id="tmpl-editor-attachment">
|
||||||
|
|
|
@ -328,10 +328,11 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'addToGallery' => __( 'Add to gallery' ),
|
'addToGallery' => __( 'Add to gallery' ),
|
||||||
|
|
||||||
// Gallery
|
// Gallery
|
||||||
'returnToLibrary' => __( 'Return to media library' ),
|
'returnToLibrary' => __( 'Return to media library' ),
|
||||||
'insertGalleryIntoPost' => __( 'Insert gallery into post' ),
|
'continueEditingGallery' => __( 'Continue editing gallery' ),
|
||||||
'updateGallery' => __( 'Update gallery' ),
|
'insertGalleryIntoPost' => __( 'Insert gallery into post' ),
|
||||||
'addImagesFromLibrary' => __( 'Add images from media library' ),
|
'updateGallery' => __( 'Update gallery' ),
|
||||||
|
'addImagesFromLibrary' => __( 'Add images from media library' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
|
$scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );
|
||||||
|
|
Loading…
Reference in New Issue