IP : 18.191.112.81Hostname : server86.web-hosting.comKernel : Linux server86.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64Disable Function : None :) OS : Linux
PATH:
/
home/
servlmvm/
public_html/
wp-includes/
./
js/
media-editor.js/
/
/** * @output wp-includes/js/media-editor.js */
/* global getUserSetting, tinymce, QTags */
// WordPress, TinyMCE, and Media // ----------------------------- (function($, _){ /** * Stores the editors' `wp.media.controller.Frame` instances. * * @static */ var workflows = {};
/** * A helper mixin function to avoid truthy and falsey values being * passed as an input that expects booleans. If key is undefined in the map, * but has a default value, set it. * * @param {Object} attrs Map of props from a shortcode or settings. * @param {string} key The key within the passed map to check for a value. * @return {mixed|undefined} The original or coerced value of key within attrs. */ wp.media.coerce = function ( attrs, key ) { if ( _.isUndefined( attrs[ key ] ) && ! _.isUndefined( this.defaults[ key ] ) ) { attrs[ key ] = this.defaults[ key ]; } else if ( 'true' === attrs[ key ] ) { attrs[ key ] = true; } else if ( 'false' === attrs[ key ] ) { attrs[ key ] = false; } return attrs[ key ]; };
/** @namespace wp.media.string */ wp.media.string = { /** * Joins the `props` and `attachment` objects, * outputting the proper object format based on the * attachment's type. * * @param {Object} [props={}] Attachment details (align, link, size, etc). * @param {Object} attachment The attachment object, media version of Post. * @return {Object} Joined props */ props: function( props, attachment ) { var link, linkUrl, size, sizes, defaultProps = wp.media.view.settings.defaultProps;
return props; }, /** * Create link markup 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. * @return {string} The link markup */ link: function( props, attachment ) { var options;
if ( props.rel ) { options.attrs.rel = props.rel; }
return wp.html.string( options ); }, /** * 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. * @return {string} The audio shortcode */ audio: function( props, attachment ) { return wp.media.string._audioVideo( 'audio', props, attachment ); }, /** * 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. * @return {string} The video shortcode */ video: function( props, attachment ) { return wp.media.string._audioVideo( 'video', props, attachment ); }, /** * Helper function to create a media shortcode string * * @access private * * @param {string} type The shortcode tag name: 'audio' or 'video'. * @param {Object} props Attachment details (align, link, size, etc). * @param {Object} attachment The attachment object, media version of Post. * @return {string} The media shortcode */ _audioVideo: function( type, props, attachment ) { var shortcode, html, extension;
if ( 'video' === type ) { if ( attachment.image && -1 === attachment.image.src.indexOf( attachment.icon ) ) { shortcode.poster = attachment.image.src; }
if ( attachment.width ) { shortcode.width = attachment.width; }
if ( attachment.height ) { shortcode.height = attachment.height; } }
extension = attachment.filename.split('.').pop();
if ( _.contains( wp.media.view.settings.embedExts, extension ) ) { shortcode[extension] = attachment.url; } else { // Render unsupported audio and video files as links. return wp.media.string.link( props ); }
html = wp.shortcode.string({ tag: type, attrs: shortcode });
return html; }, /** * Create image markup, optionally with a link and/or wrapped in a caption shortcode, * 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. * @return {string} */ image: function( props, attachment ) { var img = {}, options, classes, shortcode, html;
// Only assign the align class to the image if we're not printing // a caption, since the alignment is sent to the shortcode. if ( props.align && ! props.caption ) { classes.push( 'align' + props.align ); }
return _.extend(/** @lends wp.media.collection.prototype */{ coerce : wp.media.coerce, /** * Retrieve attachments based on the properties of the passed shortcode * * @param {wp.shortcode} shortcode An instance of wp.shortcode(). * @return {wp.media.model.Attachments} A Backbone.Collection containing * the media items belonging to a collection. * The query[ this.tag ] property is a Backbone.Model * containing the 'props' for the collection. */ attachments: function( shortcode ) { var shortcodeString = shortcode.string(), result = collections[ shortcodeString ], attrs, args, query, others, self = this;
delete collections[ shortcodeString ]; if ( result ) { return result; } // Fill the default shortcode attributes. attrs = _.defaults( shortcode.attrs.named, this.defaults ); args = _.pick( attrs, 'orderby', 'order' );
args.type = this.type; args.perPage = -1;
// Mark the `orderby` override attribute. if ( undefined !== attrs.orderby ) { attrs._orderByField = attrs.orderby; }
// Map the `orderby` attribute to the corresponding model property. if ( ! attrs.orderby || /^menu_order(?: ID)?$/i.test( attrs.orderby ) ) { args.orderby = 'menuOrder'; }
// Map the `ids` param to the correct query args. if ( attrs.ids ) { args.post__in = attrs.ids.split(','); args.orderby = 'post__in'; } else if ( attrs.include ) { args.post__in = attrs.include.split(','); }
if ( attrs.exclude ) { args.post__not_in = attrs.exclude.split(','); }
if ( ! args.post__in ) { args.uploadedTo = attrs.id; }
// Collect the attributes that were not included in `args`. others = _.omit( attrs, 'id', 'ids', 'include', 'exclude', 'orderby', 'order' );
if ( attachments[this.tag] ) { _.extend( attrs, attachments[this.tag].toJSON() ); }
/* * Convert all gallery shortcodes to use the `ids` property. * Ignore `post__in` and `post__not_in`; the attachments in * the collection will already reflect those properties. */ attrs.ids = attachments.pluck('id');
// Copy the `uploadedTo` post ID. if ( props.uploadedTo ) { attrs.id = props.uploadedTo; } // Check if the gallery is randomly ordered. delete attrs.orderby;
// If the `ids` attribute is set and `orderby` attribute // is the default value, clear it for cleaner output. if ( attrs.ids && 'post__in' === attrs.orderby ) { delete attrs.orderby; }
// Use a cloned version of the gallery. clone = new wp.media.model.Attachments( attachments.models, { props: props }); clone[ this.tag ] = attachments[ this.tag ]; collections[ shortcode.string() ] = clone;
return shortcode; }, /** * Triggered when double-clicking a collection shortcode placeholder * in the editor * * @param {string} content Content that is searched for possible * shortcode markup matching the passed tag name, * * @this wp.media.{prop} * * @return {wp.media.view.MediaFrame.Select} A media workflow. */ edit: function( content ) { var shortcode = wp.shortcode.next( this.tag, content ), defaultPostId = this.defaults.id, attachments, selection, state;
// Bail if we didn't match the shortcode or all of the content. if ( ! shortcode || shortcode.content !== content ) { return; }
// Ignore the rest of the match object. shortcode = shortcode.shortcode;
// Fetch the query's attachments, and then break ties from the // query to allow for sorting. selection.more().done( function() { // Break ties with the query. selection.props.set({ query: false }); selection.unmirror(); selection.props.unset('orderby'); });
// Destroy the previous gallery frame. if ( this.frame ) { this.frame.dispose(); }
if ( shortcode.attrs.named.type && 'video' === shortcode.attrs.named.type ) { state = 'video-' + this.tag + '-edit'; } else { state = this.tag + '-edit'; }
// Store the current frame. this.frame = wp.media({ frame: 'post', state: state, title: this.editTitle, editing: true, multiple: true, selection: selection }).open();
return this.frame; },
setDefaults: function( attrs ) { var self = this; // Remove default attributes from the shortcode. _.each( this.defaults, function( value, key ) { attrs[ key ] = self.coerce( attrs, key ); if ( value === attrs[ key ] ) { delete attrs[ key ]; } });
/** * @namespace wp.media.featuredImage * @memberOf wp.media */ wp.media.featuredImage = { /** * Get the featured image post ID * * @return {wp.media.view.settings.post.featuredImageId|number} */ get: function() { return wp.media.view.settings.post.featuredImageId; }, /** * Sets the featured image ID property and sets the HTML in the post meta box to the new featured image. * * @param {number} id The post ID of the featured image, or -1 to unset it. */ set: function( id ) { var settings = wp.media.view.settings;
settings.post.featuredImageId = id;
wp.media.post( 'get-post-thumbnail-html', { post_id: settings.post.id, thumbnail_id: settings.post.featuredImageId, _wpnonce: settings.post.nonce }).done( function( html ) { if ( '0' === html ) { window.alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) ); return; } $( '.inside', '#postimagediv' ).html( html ); }); }, /** * Remove the featured image id, save the post thumbnail data and * set the HTML in the post meta box to no featured image. */ remove: function() { wp.media.featuredImage.set( -1 ); }, /** * The Featured Image workflow * * @this wp.media.featuredImage * * @return {wp.media.view.MediaFrame.Select} A media workflow. */ frame: function() { if ( this._frame ) { wp.media.frame = this._frame; return this._frame; }
this._frame = wp.media({ state: 'featured-image', states: [ new wp.media.controller.FeaturedImage() , new wp.media.controller.EditImage() ] });
this._frame.on( 'content:render:edit-image', function() { var selection = this.state('featured-image').get('selection'), view = new wp.media.view.EditImage( { model: selection.single(), controller: this } ).render();
this.content.set( view );
// After bringing in the frame, load the actual editor via an Ajax call. view.loadEditor();
}, this._frame );
this._frame.state('featured-image').on( 'select', this.select ); return this._frame; }, /** * 'select' callback for Featured Image workflow, triggered when * the 'Set Featured Image' button is clicked in the media modal. * * @this wp.media.controller.FeaturedImage */ select: function() { var selection = this.get('selection').single();
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. * * Update the featured image id when the 'remove' link is clicked. */ init: function() { $('#postimagediv').on( 'click', '#set-post-thumbnail', function( event ) { event.preventDefault(); // Stop propagation to prevent thickbox from activating. event.stopPropagation();
/* * Delegate to the global `send_to_editor` if it exists. * This attempts to play nice with any themes/plugins * that have overridden the insert functionality. */ if ( window.send_to_editor ) { return window.send_to_editor.apply( this, arguments ); }
if ( editor && ! editor.isHidden() ) { editor.execCommand( 'mceInsertContent', false, html ); } else if ( hasQuicktags ) { QTags.insertContent( html ); } else { document.getElementById( wpActiveEditor ).value += html; }
// If the old thickbox remove function exists, call it in case // a theme/plugin overloaded it. if ( window.tb_remove ) { try { window.tb_remove(); } catch( e ) {} } },
/** * Setup 'workflow' and add to the 'workflows' cache. 'open' can * subsequently be called upon it. * * @param {string} id A slug used to identify the workflow. * @param {Object} [options={}] * * @this wp.media.editor * * @return {wp.media.view.MediaFrame.Select} A media workflow. */ add: function( id, options ) { var workflow = this.get( id );
// Only add once: if exists return existing. if ( workflow ) { return workflow; }
this.insert( wp.media.string.image( embed ) ); } }, this );
workflow.state('featured-image').on( 'select', wp.media.featuredImage.select ); workflow.setState( workflow.options.state ); return workflow; }, /** * Determines the proper current workflow id * * @param {string} [id=''] A slug used to identify the workflow. * * @return {wpActiveEditor|string|tinymce.activeEditor.id} */ id: function( id ) { if ( id ) { return id; }
// If an empty `id` is provided, default to `wpActiveEditor`. id = window.wpActiveEditor;
// If that doesn't work, fall back to `tinymce.activeEditor.id`. if ( ! id && ! _.isUndefined( window.tinymce ) && tinymce.activeEditor ) { id = tinymce.activeEditor.id; }
// Last but not least, fall back to the empty string. id = id || ''; return id; }, /** * Return the workflow specified by id * * @param {string} id A slug used to identify the workflow. * * @this wp.media.editor * * @return {wp.media.view.MediaFrame} A media workflow. */ get: function( id ) { id = this.id( id ); return workflows[ id ]; }, /** * Remove the workflow represented by id from the workflow cache * * @param {string} id A slug used to identify the workflow. * * @this wp.media.editor */ remove: function( id ) { id = this.id( id ); delete workflows[ id ]; }, /** @namespace wp.media.editor.send */ send: { /** * Called when sending an attachment to the editor * from the medial modal. * * @param {Object} props Attachment details (align, link, size, etc). * @param {Object} attachment The attachment object, media version of Post. * @return {Promise} */ attachment: function( props, attachment ) { var caption = attachment.caption, options, html;
// If captions are disabled, clear the caption. if ( ! wp.media.view.settings.captions ) { delete attachment.caption; }