Make WordPress Core

Changeset 22495


Ignore:
Timestamp:
11/09/2012 09:59:36 AM (12 years ago)
Author:
koopersmith
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/media-upload.js

    r22480 r22495  
    104104
    105105            workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
     106                frame:    'post',
    106107                title:    wp.media.view.l10n.insertMedia,
    107108                multiple: true
  • trunk/wp-includes/js/mce-view.js

    r22437 r22495  
    695695
    696696                this.frame = wp.media({
     697                    frame:     'post',
    697698                    state:     'gallery-edit',
    698699                    title:     mceview.l10n.editGallery,
  • trunk/wp-includes/js/media-models.js

    r22494 r22495  
    88     *
    99     * Handles the default media experience. Automatically creates
    10      * and opens a media workflow, and returns the result.
     10     * and opens a media frame, and returns the result.
    1111     * Does nothing if the controllers do not exist.
    1212     *
     
    1515     */
    1616    media = wp.media = function( attributes ) {
    17         if ( media.view.MediaFrame.Post )
    18             return new media.view.MediaFrame.Post( attributes ).render().attach().open();
     17        var MediaFrame = media.view.MediaFrame,
     18            frame;
     19
     20        if ( ! MediaFrame )
     21            return;
     22
     23        attributes = _.defaults( attributes || {}, {
     24            frame: 'select'
     25        });
     26
     27        if ( 'select' === attributes.frame && MediaFrame.Select )
     28            frame = new MediaFrame.Select( attributes );
     29        else if ( 'post' === attributes.frame && MediaFrame.Post )
     30            frame = new MediaFrame.Post( attributes );
     31
     32        delete attributes.frame;
     33        return frame.render().attach().open();
    1934    };
    2035
Note: See TracChangeset for help on using the changeset viewer.