diff --git a/wp-includes/js/media-editor.js b/wp-includes/js/media-editor.js index a3b5a18da5..913e34c6d5 100644 --- a/wp-includes/js/media-editor.js +++ b/wp-includes/js/media-editor.js @@ -21,6 +21,7 @@ * attachment's type. * * @global wp.media.view.settings + * @global getUserSetting() * * @param {Object} [props={}] Attachment details (align, link, size, etc). * @param {Object} attachment The attachment object, media version of Post. @@ -97,9 +98,8 @@ return fallbacks( props ); }, - /** - * Create the markup for a link + * Create link markup that is suitable for passing to the editor * * @global wp.html.string * @@ -127,7 +127,7 @@ return wp.html.string( options ); }, /** - * Create an Audio shortcode + * Create an Audio shortcode string that is suitable for passing to the editor * * @param {Object} props Attachment details (align, link, size, etc). * @param {Object} attachment The attachment object, media version of Post. @@ -137,7 +137,7 @@ return wp.media.string._audioVideo( 'audio', props, attachment ); }, /** - * Create a Video shortcode + * Create a Video shortcode string that is suitable for passing to the editor * * @param {Object} props Attachment details (align, link, size, etc). * @param {Object} attachment The attachment object, media version of Post. @@ -147,7 +147,7 @@ return wp.media.string._audioVideo( 'video', props, attachment ); }, /** - * Helper function to create a media shortcode + * Helper function to create a media shortcode string * * @access private * @@ -195,7 +195,8 @@ return html; }, /** - * Create image markup, optionally with a link and/or wrapped in a caption shortcode + * Create image markup, optionally with a link and/or wrapped in a caption shortcode, + * that is suitable for passing to the editor * * @global wp.html * @global wp.shortcode @@ -287,7 +288,10 @@ return { /** + * Default gallery properties + * * @global wp.media.view.settings + * @readonly */ defaults: { order: 'ASC', @@ -300,11 +304,12 @@ size: 'thumbnail', orderby: 'menu_order ID' }, - /** + * Retrieve attachments based on the properties of the passed shortcode + * * @global wp.media.query * - * @param {wp.shortcode} shortcode + * @param {wp.shortcode} shortcode An instance of wp.shortcode(). * @returns {wp.media.model.Attachments} A Backbone.Collection containing * the images belonging to a gallery. The 'gallery' prop is a Backbone.Model * containing the 'props' for the gallery. @@ -363,7 +368,6 @@ query.gallery = new Backbone.Model( others ); return query; }, - /** * Triggered when clicking 'Insert Gallery' or 'Update Gallery' * @@ -441,7 +445,8 @@ * @global wp.media.model.Selection * @global wp.media.view.l10n * - * @param {string} content + * @param {string} content Content that is searched for possible + * shortcode markup matching the passed tag name, * @returns {wp.media.view.MediaFrame.Select} A media workflow. */ edit: function( content ) { @@ -514,7 +519,6 @@ get: function() { return wp.media.view.settings.post.featuredImageId; }, - /** * Set the featured image id, save the post thumbnail data and * set the HTML in the post meta box to the new featured image. @@ -522,7 +526,7 @@ * @global wp.media.view.settings * @global wp.media.post * - * @param {number} id + * @param {number} id The post ID of the featured image, or -1 to unset it. */ set: function( id ) { var settings = wp.media.view.settings; @@ -571,21 +575,22 @@ return this._frame; }, /** + * 'select' callback for Featured Image workflow, triggered when + * the 'Set Featured Image' button is clicked in the media modal. + * * @global wp.media.view.settings * * @this wp.media.controller.FeaturedImage */ select: function() { - var settings = wp.media.view.settings, - selection = this.get('selection').single(); + var selection = this.get('selection').single(); - if ( ! settings.post.featuredImageId ) { + if ( ! wp.media.view.settings.post.featuredImageId ) { return; } wp.media.featuredImage.set( selection ? selection.id : -1 ); }, - /** * Open the content media manager to the 'featured image' tab when * the post thumbnail is clicked. @@ -615,11 +620,14 @@ */ wp.media.editor = { /** + * Send content to the editor + * * @global tinymce * @global QTags * @global wpActiveEditor + * @global tb_remove() - Possibly overloaded by legacy plugins * - * @param {string} html + * @param {string} html Content to send to the editor */ insert: function( html ) { var editor, @@ -661,6 +669,9 @@ }, /** + * Setup 'workflow' and add to the 'workflows' cache. 'open' can + * subsequently be called upon it. + * * @global wp.media.view.l10n * * @param {string} id A slug used to identify the workflow. @@ -753,14 +764,14 @@ workflow.setState( workflow.options.state ); return workflow; }, - /** * Determines the proper current workflow id * * @global wpActiveEditor * @global tinymce * - * @param {string} [id=''] + * @param {string} [id=''] A slug used to identify the workflow. + * * @returns {wpActiveEditor|string|tinymce.activeEditor.id} */ id: function( id ) { @@ -783,7 +794,7 @@ /** * Return the workflow specified by id * - * @param {string} id + * @param {string} id A slug used to identify the workflow. * * @this wp.media.editor * @@ -796,7 +807,7 @@ /** * Remove the workflow represented by id from the workflow cache * - * @param {string} id + * @param {string} id A slug used to identify the workflow. * * @this wp.media.editor */ @@ -804,7 +815,9 @@ id = this.id( id ); delete workflows[ id ]; }, - + /** + * @namespace + */ send: { /** * Called when sending an attachment to the editor @@ -884,7 +897,9 @@ } }, /** - * @param {string} id + * Open a workflow + * + * @param {string} [id=undefined] Optional. A slug used to identify the workflow. * @param {Object} [options={}] * * @this wp.media.editor diff --git a/wp-includes/js/media-editor.min.js b/wp-includes/js/media-editor.min.js index 3c72365b4f..816b50e5a8 100644 --- a/wp-includes/js/media-editor.min.js +++ b/wp-includes/js/media-editor.min.js @@ -1 +1 @@ -!function(a){var b={};wp.media.string={props:function(a,b){var c,d,e,f,g,h=wp.media.view.settings.defaultProps;return g=function(a){return"image"!==a.type||a.alt||(a.alt=a.caption||a.title||"",a.alt=a.alt.replace(/<\/?[^>]+>/g,""),a.alt=a.alt.replace(/[\r\n]+/g," ")),a},a=a?_.clone(a):{},b&&b.type&&(a.type=b.type),"image"===a.type&&(a=_.defaults(a||{},{align:h.align||getUserSetting("align","none"),size:h.size||getUserSetting("imgsize","medium"),url:"",classes:[]})),b?(a.title=a.title||b.title,c=a.link||h.link||getUserSetting("urlbutton","file"),"file"===c||"embed"===c?d=b.url:"post"===c?d=b.link:"custom"===c&&(d=a.linkUrl),a.linkUrl=d||"","image"===b.type?(a.classes.push("wp-image-"+b.id),f=b.sizes,e=f&&f[a.size]?f[a.size]:b,_.extend(a,_.pick(b,"align","caption","alt"),{width:e.width,height:e.height,src:e.url,captionId:"attachment_"+b.id})):"video"===b.type||"audio"===b.type?_.extend(a,_.pick(b,"title","type","icon","mime")):(a.title=a.title||b.filename,a.rel=a.rel||"attachment wp-att-"+b.id),g(a)):g(a)},link:function(a,b){var c;return a=wp.media.string.props(a,b),c={tag:"a",content:a.title,attrs:{href:a.linkUrl}},a.rel&&(c.attrs.rel=a.rel),wp.html.string(c)},audio:function(a,b){return wp.media.string._audioVideo("audio",a,b)},video:function(a,b){return wp.media.string._audioVideo("video",a,b)},_audioVideo:function(a,b,c){var d,e,f;return b=wp.media.string.props(b,c),"embed"!==b.link?wp.media.string.link(b):(d={},"video"===a&&(c.width&&(d.width=c.width),c.height&&(d.height=c.height)),f=c.filename.split(".").pop(),_.contains(wp.media.view.settings.embedExts,f)?(d[f]=c.url,e=wp.shortcode.string({tag:a,attrs:d})):wp.media.string.link(b))},image:function(a,b){var c,d,e,f,g={};return a=wp.media.string.props(a,b),d=a.classes||[],g.src="undefined"!=typeof b?b.url:a.url,_.extend(g,_.pick(a,"width","height","alt")),a.align&&!a.caption&&d.push("align"+a.align),a.size&&d.push("size-"+a.size),g["class"]=_.compact(d).join(" "),c={tag:"img",attrs:g,single:!0},a.linkUrl&&(c={tag:"a",attrs:{href:a.linkUrl},content:c}),f=wp.html.string(c),a.caption&&(e={},g.width&&(e.width=g.width),a.captionId&&(e.id=a.captionId),a.align&&(e.align="align"+a.align),f=wp.shortcode.string({tag:"caption",attrs:e,content:f+" "+a.caption})),f}},wp.media.gallery=function(){var a={};return{defaults:{order:"ASC",id:wp.media.view.settings.post.id,itemtag:"dl",icontag:"dt",captiontag:"dd",columns:"3",link:"post",size:"thumbnail",orderby:"menu_order ID"},attachments:function(b){var c,d,e,f,g=b.string(),h=a[g];return delete a[g],h?h:(c=_.defaults(b.attrs.named,wp.media.gallery.defaults),d=_.pick(c,"orderby","order"),d.type="image",d.perPage=-1,void 0!==c.orderby&&(c._orderByField=c.orderby),"rand"===c.orderby&&(c._orderbyRandom=!0),(!c.orderby||/^menu_order(?: ID)?$/i.test(c.orderby))&&(d.orderby="menuOrder"),c.ids?(d.post__in=c.ids.split(","),d.orderby="post__in"):c.include&&(d.post__in=c.include.split(",")),c.exclude&&(d.post__not_in=c.exclude.split(",")),d.post__in||(d.uploadedTo=c.id),f=_.omit(c,"id","ids","include","exclude","orderby","order"),e=wp.media.query(d),e.gallery=new Backbone.Model(f),e)},shortcode:function(b){var c,d,e=b.props.toJSON(),f=_.pick(e,"orderby","order");return b.gallery&&_.extend(f,b.gallery.toJSON()),f.ids=b.pluck("id"),e.uploadedTo&&(f.id=e.uploadedTo),delete f.orderby,f._orderbyRandom?f.orderby="rand":f._orderByField&&"rand"!=f._orderByField&&(f.orderby=f._orderByField),delete f._orderbyRandom,delete f._orderByField,f.ids&&"post__in"===f.orderby&&delete f.orderby,_.each(wp.media.gallery.defaults,function(a,b){a===f[b]&&delete f[b]}),c=new wp.shortcode({tag:"gallery",attrs:f,type:"single"}),d=new wp.media.model.Attachments(b.models,{props:e}),d.gallery=b.gallery,a[c.string()]=d,c},edit:function(a){var b,c,d=wp.shortcode.next("gallery",a),e=wp.media.gallery.defaults.id;if(d&&d.content===a)return d=d.shortcode,_.isUndefined(d.get("id"))&&!_.isUndefined(e)&&d.set("id",e),b=wp.media.gallery.attachments(d),c=new wp.media.model.Selection(b.models,{props:b.props.toJSON(),multiple:!0}),c.gallery=b.gallery,c.more().done(function(){c.props.set({query:!1}),c.unmirror(),c.props.unset("orderby")}),this.frame&&this.frame.dispose(),this.frame=wp.media({frame:"post",state:"gallery-edit",title:wp.media.view.l10n.editGalleryTitle,editing:!0,multiple:!0,selection:c}).open(),this.frame}}}(),wp.media.featuredImage={get:function(){return wp.media.view.settings.post.featuredImageId},set:function(b){var c=wp.media.view.settings;c.post.featuredImageId=b,wp.media.post("set-post-thumbnail",{json:!0,post_id:c.post.id,thumbnail_id:c.post.featuredImageId,_wpnonce:c.post.nonce}).done(function(b){a(".inside","#postimagediv").html(b)})},frame:function(){return this._frame?this._frame:(this._frame=wp.media({state:"featured-image",states:[new wp.media.controller.FeaturedImage]}),this._frame.on("toolbar:create:featured-image",function(a){this.createSelectToolbar(a,{text:wp.media.view.l10n.setFeaturedImage})},this._frame),this._frame.state("featured-image").on("select",this.select),this._frame)},select:function(){var a=wp.media.view.settings,b=this.get("selection").single();a.post.featuredImageId&&wp.media.featuredImage.set(b?b.id:-1)},init:function(){a("#postimagediv").on("click","#set-post-thumbnail",function(a){a.preventDefault(),a.stopPropagation(),wp.media.featuredImage.frame().open()}).on("click","#remove-post-thumbnail",function(){wp.media.view.settings.post.featuredImageId=-1})}},a(wp.media.featuredImage.init),wp.media.editor={insert:function(a){var b,c="undefined"!=typeof tinymce,d="undefined"!=typeof QTags,e=window.wpActiveEditor;if(window.send_to_editor)return window.send_to_editor.apply(this,arguments);if(e)c&&(b=tinymce.get(e));else if(c&&tinymce.activeEditor)b=tinymce.activeEditor,e=window.wpActiveEditor=b.id;else if(!d)return!1;if(b&&!b.isHidden()?b.execCommand("mceInsertContent",!1,a):d?QTags.insertContent(a):document.getElementById(e).value+=a,window.tb_remove)try{window.tb_remove()}catch(f){}},add:function(c,d){var e=this.get(c);return e?e:(e=b[c]=wp.media(_.defaults(d||{},{frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0})),e.on("insert",function(b){var c=e.state();b=b||c.get("selection"),b&&a.when.apply(a,b.map(function(a){var b=c.display(a).toJSON();return this.send.attachment(b,a.toJSON())},this)).done(function(){wp.media.editor.insert(_.toArray(arguments).join("\n\n"))})},this),e.state("gallery-edit").on("update",function(a){this.insert(wp.media.gallery.shortcode(a).string())},this),e.state("embed").on("select",function(){var a=e.state(),b=a.get("type"),c=a.props.toJSON();c.url=c.url||"","link"===b?(_.defaults(c,{title:c.url,linkUrl:c.url}),this.send.link(c).done(function(a){wp.media.editor.insert(a)})):"image"===b&&(_.defaults(c,{title:c.url,linkUrl:"",align:"none",link:"none"}),"none"===c.link?c.linkUrl="":"file"===c.link&&(c.linkUrl=c.url),this.insert(wp.media.string.image(c)))},this),e.state("featured-image").on("select",wp.media.featuredImage.select),e.setState(e.options.state),e)},id:function(a){return a?a:(a=wpActiveEditor,!a&&"undefined"!=typeof tinymce&&tinymce.activeEditor&&(a=tinymce.activeEditor.id),a=a||"")},get:function(a){return a=this.id(a),b[a]},remove:function(a){a=this.id(a),delete b[a]},send:{attachment:function(a,b){var c,d,e=b.caption;return wp.media.view.settings.captions||delete b.caption,a=wp.media.string.props(a,b),c={id:b.id,post_content:b.description,post_excerpt:e},a.linkUrl&&(c.url=a.linkUrl),"image"===b.type?(d=wp.media.string.image(a),_.each({align:"align",size:"image-size",alt:"image_alt"},function(b,d){a[d]&&(c[b]=a[d])})):"video"===b.type?d=wp.media.string.video(a,b):"audio"===b.type?d=wp.media.string.audio(a,b):(d=wp.media.string.link(a),c.post_title=a.title),wp.media.post("send-attachment-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:c,html:d,post_id:wp.media.view.settings.post.id})},link:function(a){return wp.media.post("send-link-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,src:a.linkUrl,title:a.title,html:wp.media.string.link(a),post_id:wp.media.view.settings.post.id})}},open:function(a,b){var c;return b=b||{},a=this.id(a),c=this.get(a),(!c||c.options&&b.state!==c.options.state)&&(c=this.add(a,b)),c.open()},init:function(){a(document.body).on("click",".insert-media",function(b){var c=a(b.currentTarget),d=c.data("editor"),e={frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0};b.preventDefault(),c.blur(),c.hasClass("gallery")&&(e.state="gallery",e.title=wp.media.view.l10n.createGalleryTitle),wp.media.editor.open(d,e)})}},_.bindAll(wp.media.editor,"open"),a(wp.media.editor.init)}(jQuery); \ No newline at end of file +!function(a){var b={};wp.media.string={props:function(a,b){var c,d,e,f,g,h=wp.media.view.settings.defaultProps;return g=function(a){return"image"!==a.type||a.alt||(a.alt=a.caption||a.title||"",a.alt=a.alt.replace(/<\/?[^>]+>/g,""),a.alt=a.alt.replace(/[\r\n]+/g," ")),a},a=a?_.clone(a):{},b&&b.type&&(a.type=b.type),"image"===a.type&&(a=_.defaults(a||{},{align:h.align||getUserSetting("align","none"),size:h.size||getUserSetting("imgsize","medium"),url:"",classes:[]})),b?(a.title=a.title||b.title,c=a.link||h.link||getUserSetting("urlbutton","file"),"file"===c||"embed"===c?d=b.url:"post"===c?d=b.link:"custom"===c&&(d=a.linkUrl),a.linkUrl=d||"","image"===b.type?(a.classes.push("wp-image-"+b.id),f=b.sizes,e=f&&f[a.size]?f[a.size]:b,_.extend(a,_.pick(b,"align","caption","alt"),{width:e.width,height:e.height,src:e.url,captionId:"attachment_"+b.id})):"video"===b.type||"audio"===b.type?_.extend(a,_.pick(b,"title","type","icon","mime")):(a.title=a.title||b.filename,a.rel=a.rel||"attachment wp-att-"+b.id),g(a)):g(a)},link:function(a,b){var c;return a=wp.media.string.props(a,b),c={tag:"a",content:a.title,attrs:{href:a.linkUrl}},a.rel&&(c.attrs.rel=a.rel),wp.html.string(c)},audio:function(a,b){return wp.media.string._audioVideo("audio",a,b)},video:function(a,b){return wp.media.string._audioVideo("video",a,b)},_audioVideo:function(a,b,c){var d,e,f;return b=wp.media.string.props(b,c),"embed"!==b.link?wp.media.string.link(b):(d={},"video"===a&&(c.width&&(d.width=c.width),c.height&&(d.height=c.height)),f=c.filename.split(".").pop(),_.contains(wp.media.view.settings.embedExts,f)?(d[f]=c.url,e=wp.shortcode.string({tag:a,attrs:d})):wp.media.string.link(b))},image:function(a,b){var c,d,e,f,g={};return a=wp.media.string.props(a,b),d=a.classes||[],g.src="undefined"!=typeof b?b.url:a.url,_.extend(g,_.pick(a,"width","height","alt")),a.align&&!a.caption&&d.push("align"+a.align),a.size&&d.push("size-"+a.size),g["class"]=_.compact(d).join(" "),c={tag:"img",attrs:g,single:!0},a.linkUrl&&(c={tag:"a",attrs:{href:a.linkUrl},content:c}),f=wp.html.string(c),a.caption&&(e={},g.width&&(e.width=g.width),a.captionId&&(e.id=a.captionId),a.align&&(e.align="align"+a.align),f=wp.shortcode.string({tag:"caption",attrs:e,content:f+" "+a.caption})),f}},wp.media.gallery=function(){var a={};return{defaults:{order:"ASC",id:wp.media.view.settings.post.id,itemtag:"dl",icontag:"dt",captiontag:"dd",columns:"3",link:"post",size:"thumbnail",orderby:"menu_order ID"},attachments:function(b){var c,d,e,f,g=b.string(),h=a[g];return delete a[g],h?h:(c=_.defaults(b.attrs.named,wp.media.gallery.defaults),d=_.pick(c,"orderby","order"),d.type="image",d.perPage=-1,void 0!==c.orderby&&(c._orderByField=c.orderby),"rand"===c.orderby&&(c._orderbyRandom=!0),(!c.orderby||/^menu_order(?: ID)?$/i.test(c.orderby))&&(d.orderby="menuOrder"),c.ids?(d.post__in=c.ids.split(","),d.orderby="post__in"):c.include&&(d.post__in=c.include.split(",")),c.exclude&&(d.post__not_in=c.exclude.split(",")),d.post__in||(d.uploadedTo=c.id),f=_.omit(c,"id","ids","include","exclude","orderby","order"),e=wp.media.query(d),e.gallery=new Backbone.Model(f),e)},shortcode:function(b){var c,d,e=b.props.toJSON(),f=_.pick(e,"orderby","order");return b.gallery&&_.extend(f,b.gallery.toJSON()),f.ids=b.pluck("id"),e.uploadedTo&&(f.id=e.uploadedTo),delete f.orderby,f._orderbyRandom?f.orderby="rand":f._orderByField&&"rand"!=f._orderByField&&(f.orderby=f._orderByField),delete f._orderbyRandom,delete f._orderByField,f.ids&&"post__in"===f.orderby&&delete f.orderby,_.each(wp.media.gallery.defaults,function(a,b){a===f[b]&&delete f[b]}),c=new wp.shortcode({tag:"gallery",attrs:f,type:"single"}),d=new wp.media.model.Attachments(b.models,{props:e}),d.gallery=b.gallery,a[c.string()]=d,c},edit:function(a){var b,c,d=wp.shortcode.next("gallery",a),e=wp.media.gallery.defaults.id;if(d&&d.content===a)return d=d.shortcode,_.isUndefined(d.get("id"))&&!_.isUndefined(e)&&d.set("id",e),b=wp.media.gallery.attachments(d),c=new wp.media.model.Selection(b.models,{props:b.props.toJSON(),multiple:!0}),c.gallery=b.gallery,c.more().done(function(){c.props.set({query:!1}),c.unmirror(),c.props.unset("orderby")}),this.frame&&this.frame.dispose(),this.frame=wp.media({frame:"post",state:"gallery-edit",title:wp.media.view.l10n.editGalleryTitle,editing:!0,multiple:!0,selection:c}).open(),this.frame}}}(),wp.media.featuredImage={get:function(){return wp.media.view.settings.post.featuredImageId},set:function(b){var c=wp.media.view.settings;c.post.featuredImageId=b,wp.media.post("set-post-thumbnail",{json:!0,post_id:c.post.id,thumbnail_id:c.post.featuredImageId,_wpnonce:c.post.nonce}).done(function(b){a(".inside","#postimagediv").html(b)})},frame:function(){return this._frame?this._frame:(this._frame=wp.media({state:"featured-image",states:[new wp.media.controller.FeaturedImage]}),this._frame.on("toolbar:create:featured-image",function(a){this.createSelectToolbar(a,{text:wp.media.view.l10n.setFeaturedImage})},this._frame),this._frame.state("featured-image").on("select",this.select),this._frame)},select:function(){var a=this.get("selection").single();wp.media.view.settings.post.featuredImageId&&wp.media.featuredImage.set(a?a.id:-1)},init:function(){a("#postimagediv").on("click","#set-post-thumbnail",function(a){a.preventDefault(),a.stopPropagation(),wp.media.featuredImage.frame().open()}).on("click","#remove-post-thumbnail",function(){wp.media.view.settings.post.featuredImageId=-1})}},a(wp.media.featuredImage.init),wp.media.editor={insert:function(a){var b,c="undefined"!=typeof tinymce,d="undefined"!=typeof QTags,e=window.wpActiveEditor;if(window.send_to_editor)return window.send_to_editor.apply(this,arguments);if(e)c&&(b=tinymce.get(e));else if(c&&tinymce.activeEditor)b=tinymce.activeEditor,e=window.wpActiveEditor=b.id;else if(!d)return!1;if(b&&!b.isHidden()?b.execCommand("mceInsertContent",!1,a):d?QTags.insertContent(a):document.getElementById(e).value+=a,window.tb_remove)try{window.tb_remove()}catch(f){}},add:function(c,d){var e=this.get(c);return e?e:(e=b[c]=wp.media(_.defaults(d||{},{frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0})),e.on("insert",function(b){var c=e.state();b=b||c.get("selection"),b&&a.when.apply(a,b.map(function(a){var b=c.display(a).toJSON();return this.send.attachment(b,a.toJSON())},this)).done(function(){wp.media.editor.insert(_.toArray(arguments).join("\n\n"))})},this),e.state("gallery-edit").on("update",function(a){this.insert(wp.media.gallery.shortcode(a).string())},this),e.state("embed").on("select",function(){var a=e.state(),b=a.get("type"),c=a.props.toJSON();c.url=c.url||"","link"===b?(_.defaults(c,{title:c.url,linkUrl:c.url}),this.send.link(c).done(function(a){wp.media.editor.insert(a)})):"image"===b&&(_.defaults(c,{title:c.url,linkUrl:"",align:"none",link:"none"}),"none"===c.link?c.linkUrl="":"file"===c.link&&(c.linkUrl=c.url),this.insert(wp.media.string.image(c)))},this),e.state("featured-image").on("select",wp.media.featuredImage.select),e.setState(e.options.state),e)},id:function(a){return a?a:(a=wpActiveEditor,!a&&"undefined"!=typeof tinymce&&tinymce.activeEditor&&(a=tinymce.activeEditor.id),a=a||"")},get:function(a){return a=this.id(a),b[a]},remove:function(a){a=this.id(a),delete b[a]},send:{attachment:function(a,b){var c,d,e=b.caption;return wp.media.view.settings.captions||delete b.caption,a=wp.media.string.props(a,b),c={id:b.id,post_content:b.description,post_excerpt:e},a.linkUrl&&(c.url=a.linkUrl),"image"===b.type?(d=wp.media.string.image(a),_.each({align:"align",size:"image-size",alt:"image_alt"},function(b,d){a[d]&&(c[b]=a[d])})):"video"===b.type?d=wp.media.string.video(a,b):"audio"===b.type?d=wp.media.string.audio(a,b):(d=wp.media.string.link(a),c.post_title=a.title),wp.media.post("send-attachment-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:c,html:d,post_id:wp.media.view.settings.post.id})},link:function(a){return wp.media.post("send-link-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,src:a.linkUrl,title:a.title,html:wp.media.string.link(a),post_id:wp.media.view.settings.post.id})}},open:function(a,b){var c;return b=b||{},a=this.id(a),c=this.get(a),(!c||c.options&&b.state!==c.options.state)&&(c=this.add(a,b)),c.open()},init:function(){a(document.body).on("click",".insert-media",function(b){var c=a(b.currentTarget),d=c.data("editor"),e={frame:"post",state:"insert",title:wp.media.view.l10n.addMedia,multiple:!0};b.preventDefault(),c.blur(),c.hasClass("gallery")&&(e.state="gallery",e.title=wp.media.view.l10n.createGalleryTitle),wp.media.editor.open(d,e)})}},_.bindAll(wp.media.editor,"open"),a(wp.media.editor.init)}(jQuery); \ No newline at end of file