Ticket #41052: 41052-2.video.patch
File 41052-2.video.patch, 2.5 KB (added by , 8 years ago) |
---|
-
src/wp-admin/js/widgets/media-widgets.js
146 146 */ 147 147 fetch: function() { 148 148 var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser, url, re, youTubeEmbedMatch; // eslint-disable-line consistent-this 149 url = embedLinkView.model.get( 'url' ); 149 150 150 151 if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) { 151 152 embedLinkView.dfd.abort(); … … 152 153 } 153 154 154 155 // Abort if the URL field was emptied out. 155 if ( ! embedLinkView.model.get( 'url' )) {156 if ( ! url ) { 156 157 embedLinkView.setErrorNotice( '' ); 157 158 return; 158 159 } 159 160 161 // only proceed with embed if the field contains more than 11 characters 162 // Example: http://a.io is 11 chars 163 if ( url && ( url.length < 11 || ! url.match(/(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/) ) ) { 164 var embedLinkView = this; // eslint-disable-line consistent-this 165 $( '#embed-url-field' ).addClass( 'invalid' ); 166 embedLinkView.setAddToWidgetButtonDisabled( true ); 167 return; 168 } 169 160 170 fetchSuccess = function( response ) { 161 171 embedLinkView.renderoEmbed({ 162 172 data: { … … 170 180 }; 171 181 172 182 urlParser = document.createElement( 'a' ); 173 urlParser.href = embedLinkView.model.get( 'url' );183 urlParser.href = url; 174 184 matches = urlParser.pathname.toLowerCase().match( /\.(\w+)$/ ); 175 185 if ( matches ) { 176 186 fileExt = matches[1]; … … 191 201 } 192 202 193 203 // Support YouTube embed links. 194 url = embedLinkView.model.get( 'url' );195 204 re = /https?:\/\/www\.youtube\.com\/embed\/([^/]+)/; 196 205 youTubeEmbedMatch = re.exec( url ); 197 206 if ( youTubeEmbedMatch ) { -
src/wp-includes/js/media-views.js
4733 4733 this.$('.embed-container').hide().find('.embed-preview').empty(); 4734 4734 this.$( '.setting' ).hide(); 4735 4735 4736 // only proceed with embed if the field contains more than 11 characters 4737 // Example: http://a.io is 11 chars 4738 if ( url && ( url.length < 11 || ! url.match(/^http(s)?:\/\//) ) ) { 4736 // If URL is blank. 4737 if ( ! url ) { 4739 4738 return; 4740 4739 } 4741 4740