Media JS: Use basic upload/library by default.
`wp.media` now recognizes the `frame` attribute (currently a string; either'select' or 'post') and defaults to using a basic select frame. It also checks for the existence of classes in a safer fashion, as it does not assume the `MediaFrame` property exists. see #21390. git-svn-id: http://core.svn.wordpress.org/trunk@22495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9c7acdfe7c
commit
4a008574d2
|
@ -103,6 +103,7 @@ var tb_position;
|
|||
return workflow;
|
||||
|
||||
workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
|
||||
frame: 'post',
|
||||
title: wp.media.view.l10n.insertMedia,
|
||||
multiple: true
|
||||
} ) );
|
||||
|
|
|
@ -694,6 +694,7 @@ window.wp = window.wp || {};
|
|||
return;
|
||||
|
||||
this.frame = wp.media({
|
||||
frame: 'post',
|
||||
state: 'gallery-edit',
|
||||
title: mceview.l10n.editGallery,
|
||||
editing: true,
|
||||
|
|
|
@ -7,15 +7,30 @@ window.wp = window.wp || {};
|
|||
* wp.media( attributes )
|
||||
*
|
||||
* Handles the default media experience. Automatically creates
|
||||
* and opens a media workflow, and returns the result.
|
||||
* and opens a media frame, and returns the result.
|
||||
* Does nothing if the controllers do not exist.
|
||||
*
|
||||
* @param {object} attributes The properties passed to the main media controller.
|
||||
* @return {object} A media workflow.
|
||||
*/
|
||||
media = wp.media = function( attributes ) {
|
||||
if ( media.view.MediaFrame.Post )
|
||||
return new media.view.MediaFrame.Post( attributes ).render().attach().open();
|
||||
var MediaFrame = media.view.MediaFrame,
|
||||
frame;
|
||||
|
||||
if ( ! MediaFrame )
|
||||
return;
|
||||
|
||||
attributes = _.defaults( attributes || {}, {
|
||||
frame: 'select'
|
||||
});
|
||||
|
||||
if ( 'select' === attributes.frame && MediaFrame.Select )
|
||||
frame = new MediaFrame.Select( attributes );
|
||||
else if ( 'post' === attributes.frame && MediaFrame.Post )
|
||||
frame = new MediaFrame.Post( attributes );
|
||||
|
||||
delete attributes.frame;
|
||||
return frame.render().attach().open();
|
||||
};
|
||||
|
||||
_.extend( media, { model: {}, view: {}, controller: {} });
|
||||
|
|
Loading…
Reference in New Issue