Changeset 41179
- Timestamp:
- 07/28/2017 02:35:56 AM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/widgets/media-widgets.js
r40941 r41179 146 146 */ 147 147 fetch: function() { 148 var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser ; // eslint-disable-line consistent-this148 var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser, url, re, youTubeEmbedMatch; // eslint-disable-line consistent-this 149 149 150 150 if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) { … … 191 191 } 192 192 193 // Support YouTube embed links. 194 url = embedLinkView.model.get( 'url' ); 195 re = /https?:\/\/www\.youtube\.com\/embed\/([^/]+)/; 196 youTubeEmbedMatch = re.exec( url ); 197 if ( youTubeEmbedMatch ) { 198 url = 'https://www.youtube.com/watch?v=' + youTubeEmbedMatch[ 1 ]; 199 // silently change url to proper oembed-able version. 200 embedLinkView.model.attributes.url = url; 201 } 202 193 203 embedLinkView.dfd = $.ajax({ 194 204 url: wp.media.view.settings.oEmbedProxyUrl, 195 205 data: { 196 url: embedLinkView.model.get( 'url' ),206 url: url, 197 207 maxwidth: embedLinkView.model.get( 'width' ), 198 208 maxheight: embedLinkView.model.get( 'height' ), -
trunk/src/wp-includes/js/media-views.js
r41009 r41179 4625 4625 4626 4626 fetch: function() { 4627 var url = this.model.get( 'url' ), re, youTubeEmbedMatch; 4627 4628 4628 4629 // check if they haven't typed in 500 ms 4629 if ( $('#embed-url-field').val() !== this.model.get('url')) {4630 if ( $('#embed-url-field').val() !== url ) { 4630 4631 return; 4631 4632 } … … 4633 4634 if ( this.dfd && 'pending' === this.dfd.state() ) { 4634 4635 this.dfd.abort(); 4636 } 4637 4638 // Support YouTube embed urls, since they work once in the editor. 4639 re = /https?:\/\/www\.youtube\.com\/embed\/([^/]+)/; 4640 youTubeEmbedMatch = re.exec( url ); 4641 if ( youTubeEmbedMatch ) { 4642 url = 'https://www.youtube.com/watch?v=' + youTubeEmbedMatch[ 1 ]; 4635 4643 } 4636 4644 … … 4638 4646 url: wp.media.view.settings.oEmbedProxyUrl, 4639 4647 data: { 4640 url: this.model.get( 'url' ),4648 url: url, 4641 4649 maxwidth: this.model.get( 'width' ), 4642 4650 maxheight: this.model.get( 'height' ), -
trunk/src/wp-includes/js/media/views/embed/link.js
r40628 r41179 36 36 37 37 fetch: function() { 38 var url = this.model.get( 'url' ), re, youTubeEmbedMatch; 38 39 39 40 // check if they haven't typed in 500 ms 40 if ( $('#embed-url-field').val() !== this.model.get('url')) {41 if ( $('#embed-url-field').val() !== url ) { 41 42 return; 42 43 } … … 46 47 } 47 48 49 // Support YouTube embed urls, since they work once in the editor. 50 re = /https?:\/\/www\.youtube\.com\/embed\/([^/]+)/; 51 youTubeEmbedMatch = re.exec( url ); 52 if ( youTubeEmbedMatch ) { 53 url = 'https://www.youtube.com/watch?v=' + youTubeEmbedMatch[ 1 ]; 54 } 55 48 56 this.dfd = $.ajax({ 49 57 url: wp.media.view.settings.oEmbedProxyUrl, 50 58 data: { 51 url: this.model.get( 'url' ),59 url: url, 52 60 maxwidth: this.model.get( 'width' ), 53 61 maxheight: this.model.get( 'height' ),
Note: See TracChangeset
for help on using the changeset viewer.