diff --git a/wp-admin/js/custom-background.js b/wp-admin/js/custom-background.js index fd22cc56a7..c41ca6b00b 100644 --- a/wp-admin/js/custom-background.js +++ b/wp-admin/js/custom-background.js @@ -32,7 +32,7 @@ } // Create the media frame. - frame = wp.media({ + frame = wp.media.frames.customBackground = wp.media({ // Set the title of the modal. title: $el.data('choose'), diff --git a/wp-admin/js/custom-header.js b/wp-admin/js/custom-header.js index d858359238..d93ac3895c 100644 --- a/wp-admin/js/custom-header.js +++ b/wp-admin/js/custom-header.js @@ -18,8 +18,14 @@ var $el = $(this); event.preventDefault(); + // If the media frame already exists, reopen it. + if ( frame ) { + frame.open(); + return; + } + // Create the media frame. - frame = wp.media({ + frame = wp.media.frames.customHeader = wp.media({ // Set the title of the modal. title: $el.data('choose'), diff --git a/wp-includes/js/media-models.js b/wp-includes/js/media-models.js index afc9e7d518..34cce0b7ad 100644 --- a/wp-includes/js/media-models.js +++ b/wp-includes/js/media-models.js @@ -34,7 +34,7 @@ window.wp = window.wp || {}; return frame; }; - _.extend( media, { model: {}, view: {}, controller: {} }); + _.extend( media, { model: {}, view: {}, controller: {}, frames: {} }); // Link any localized strings. l10n = media.model.l10n = typeof _wpMediaModelsL10n === 'undefined' ? {} : _wpMediaModelsL10n; @@ -216,6 +216,13 @@ window.wp = window.wp || {}; * ======================================================================== */ + /** + * wp.media.attachment + */ + media.attachment = function( id ) { + return Attachment.get( id ); + }; + /** * wp.media.model.Attachment */