Changeset 41933
- Timestamp:
- 10/19/2017 12:06:25 AM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/widgets/media-video-widget.js
r41764 r41933 139 139 * @deprecated since 4.9. 140 140 * 141 * @param {String} url - Video url.142 141 * @returns {boolean} Whether url is a supported video host. 143 142 */ 144 143 isHostedVideo: function isHostedVideo() { 145 return false;144 return true; 146 145 }, 147 146 -
trunk/src/wp-admin/js/widgets/media-widgets.js
r41759 r41933 84 84 */ 85 85 component.MediaEmbedView = wp.media.view.Embed.extend({ 86 87 /** 88 * Initialize. 89 * 90 * @since 4.9.0 91 * 92 * @param {object} options - Options. 93 * @returns {void} 94 */ 95 initialize: function( options ) { 96 var view = this, embedController; // eslint-disable-line consistent-thi 97 wp.media.view.Embed.prototype.initialize.call( view, options ); 98 if ( 'image' !== view.controller.options.mimeType ) { 99 embedController = view.controller.states.get( 'embed' ); 100 embedController.off( 'scan', embedController.scanImage, embedController ); 101 } 102 }, 86 103 87 104 /** … … 141 158 142 159 /** 160 * Update oEmbed. 161 * 162 * @since 4.9.0 163 * 164 * @returns {void} 165 */ 166 updateoEmbed: function() { 167 var embedLinkView = this, url; // eslint-disable-line consistent-this 168 169 url = embedLinkView.model.get( 'url' ); 170 171 // Abort if the URL field was emptied out. 172 if ( ! url ) { 173 embedLinkView.setErrorNotice( '' ); 174 embedLinkView.setAddToWidgetButtonDisabled( true ); 175 return; 176 } 177 178 if ( ! url.match( /^(http|https):\/\/.+\// ) ) { 179 embedLinkView.controller.$el.find( '#embed-url-field' ).addClass( 'invalid' ); 180 embedLinkView.setAddToWidgetButtonDisabled( true ); 181 } 182 183 wp.media.view.EmbedLink.prototype.updateoEmbed.call( embedLinkView ); 184 }, 185 186 /** 143 187 * Fetch media. 144 188 * … … 147 191 fetch: function() { 148 192 var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser, url, re, youTubeEmbedMatch; // eslint-disable-line consistent-this 193 url = embedLinkView.model.get( 'url' ); 149 194 150 195 if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) { 151 196 embedLinkView.dfd.abort(); 152 }153 154 // Abort if the URL field was emptied out.155 if ( ! embedLinkView.model.get( 'url' ) ) {156 embedLinkView.setErrorNotice( '' );157 return;158 197 } 159 198 … … 165 204 }); 166 205 167 $( '#embed-url-field' ).removeClass( 'invalid' );206 embedLinkView.controller.$el.find( '#embed-url-field' ).removeClass( 'invalid' ); 168 207 embedLinkView.setErrorNotice( '' ); 169 208 embedLinkView.setAddToWidgetButtonDisabled( false ); … … 171 210 172 211 urlParser = document.createElement( 'a' ); 173 urlParser.href = embedLinkView.model.get( 'url' );212 urlParser.href = url; 174 213 matches = urlParser.pathname.toLowerCase().match( /\.(\w+)$/ ); 175 214 if ( matches ) { … … 186 225 187 226 // Support YouTube embed links. 188 url = embedLinkView.model.get( 'url' );189 227 re = /https?:\/\/www\.youtube\.com\/embed\/([^/]+)/; 190 228 youTubeEmbedMatch = re.exec( url ); … … 229 267 renderFail: function renderFail() { 230 268 var embedLinkView = this; // eslint-disable-line consistent-this 231 $( '#embed-url-field' ).addClass( 'invalid' );269 embedLinkView.controller.$el.find( '#embed-url-field' ).addClass( 'invalid' ); 232 270 embedLinkView.setErrorNotice( embedLinkView.controller.options.invalidEmbedTypeError || 'ERROR' ); 233 271 embedLinkView.setAddToWidgetButtonDisabled( true ); -
trunk/src/wp-includes/widgets/class-wp-widget-media-video.php
r41827 r41933 42 42 'media_library_state_single' => __( 'Video Widget' ), 43 43 /* translators: %s: a list of valid video file extensions */ 44 'unsupported_file_type' => sprintf( __( 'Sorry, we can’t display the video file type selected. Please select a supported video file (%s) or stream (e.g. YouTube and Vimeo) instead.' ), '<code>.' . implode( '</code>, <code>.', wp_get_video_extensions() ) . '</code>' ),44 'unsupported_file_type' => sprintf( __( 'Sorry, we can’t load the video at the supplied URL. Please check that the URL is for a supported video file (%s) or stream (e.g. YouTube and Vimeo).' ), '<code>.' . implode( '</code>, <code>.', wp_get_video_extensions() ) . '</code>' ), 45 45 ) ); 46 46 }
Note: See TracChangeset
for help on using the changeset viewer.