wp/wp-admin/js/widgets/media-image-widget.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    38 		} ),
    38 		} ),
    39 
    39 
    40 		/**
    40 		/**
    41 		 * Render preview.
    41 		 * Render preview.
    42 		 *
    42 		 *
    43 		 * @returns {void}
    43 		 * @return {void}
    44 		 */
    44 		 */
    45 		renderPreview: function renderPreview() {
    45 		renderPreview: function renderPreview() {
    46 			var control = this, previewContainer, previewTemplate, fieldsContainer, fieldsTemplate, linkInput;
    46 			var control = this, previewContainer, previewTemplate, fieldsContainer, fieldsTemplate, linkInput;
    47 			if ( ! control.model.get( 'attachment_id' ) && ! control.model.get( 'url' ) ) {
    47 			if ( ! control.model.get( 'attachment_id' ) && ! control.model.get( 'url' ) ) {
    48 				return;
    48 				return;
    62 		},
    62 		},
    63 
    63 
    64 		/**
    64 		/**
    65 		 * Open the media image-edit frame to modify the selected item.
    65 		 * Open the media image-edit frame to modify the selected item.
    66 		 *
    66 		 *
    67 		 * @returns {void}
    67 		 * @return {void}
    68 		 */
    68 		 */
    69 		editMedia: function editMedia() {
    69 		editMedia: function editMedia() {
    70 			var control = this, mediaFrame, updateCallback, defaultSync, metadata;
    70 			var control = this, mediaFrame, updateCallback, defaultSync, metadata;
    71 
    71 
    72 			metadata = control.mapModelToMediaFrameProps( control.model.toJSON() );
    72 			metadata = control.mapModelToMediaFrameProps( control.model.toJSON() );
   117 		},
   117 		},
   118 
   118 
   119 		/**
   119 		/**
   120 		 * Get props which are merged on top of the model when an embed is chosen (as opposed to an attachment).
   120 		 * Get props which are merged on top of the model when an embed is chosen (as opposed to an attachment).
   121 		 *
   121 		 *
   122 		 * @returns {Object} Reset/override props.
   122 		 * @return {Object} Reset/override props.
   123 		 */
   123 		 */
   124 		getEmbedResetProps: function getEmbedResetProps() {
   124 		getEmbedResetProps: function getEmbedResetProps() {
   125 			return _.extend(
   125 			return _.extend(
   126 				component.MediaWidgetControl.prototype.getEmbedResetProps.call( this ),
   126 				component.MediaWidgetControl.prototype.getEmbedResetProps.call( this ),
   127 				{
   127 				{
   136 		 * Get the instance props from the media selection frame.
   136 		 * Get the instance props from the media selection frame.
   137 		 *
   137 		 *
   138 		 * Prevent the image_title attribute from being initially set when adding an image from the media library.
   138 		 * Prevent the image_title attribute from being initially set when adding an image from the media library.
   139 		 *
   139 		 *
   140 		 * @param {wp.media.view.MediaFrame.Select} mediaFrame - Select frame.
   140 		 * @param {wp.media.view.MediaFrame.Select} mediaFrame - Select frame.
   141 		 * @returns {Object} Props.
   141 		 * @return {Object} Props.
   142 		 */
   142 		 */
   143 		getModelPropsFromMediaFrame: function getModelPropsFromMediaFrame( mediaFrame ) {
   143 		getModelPropsFromMediaFrame: function getModelPropsFromMediaFrame( mediaFrame ) {
   144 			var control = this;
   144 			var control = this;
   145 			return _.omit(
   145 			return _.omit(
   146 				component.MediaWidgetControl.prototype.getModelPropsFromMediaFrame.call( control, mediaFrame ),
   146 				component.MediaWidgetControl.prototype.getModelPropsFromMediaFrame.call( control, mediaFrame ),
   149 		},
   149 		},
   150 
   150 
   151 		/**
   151 		/**
   152 		 * Map model props to preview template props.
   152 		 * Map model props to preview template props.
   153 		 *
   153 		 *
   154 		 * @returns {Object} Preview template props.
   154 		 * @return {Object} Preview template props.
   155 		 */
   155 		 */
   156 		mapModelToPreviewTemplateProps: function mapModelToPreviewTemplateProps() {
   156 		mapModelToPreviewTemplateProps: function mapModelToPreviewTemplateProps() {
   157 			var control = this, previewTemplateProps, url;
   157 			var control = this, previewTemplateProps, url;
   158 			url = control.model.get( 'url' );
   158 			url = control.model.get( 'url' );
   159 			previewTemplateProps = component.MediaWidgetControl.prototype.mapModelToPreviewTemplateProps.call( control );
   159 			previewTemplateProps = component.MediaWidgetControl.prototype.mapModelToPreviewTemplateProps.call( control );