Ticket #40771: 40771.3.diff
File 40771.3.diff, 3.7 KB (added by , 3 years ago) |
---|
-
src/wp-admin/js/widgets/media-widgets.js
142 142 /** 143 143 * Fetch media. 144 144 * 145 * This is a TEMPORARY measure until the WP API supports an oEmbed proxy endpoint. See #40450.146 *147 * @see https://core.trac.wordpress.org/ticket/40450148 145 * @returns {void} 149 146 */ 150 147 fetch: function() { 151 var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser; // eslint-disable-line consistent-this 148 var embedLinkView = this, fetchSuccess, matches, fileExt, urlParser, url; // eslint-disable-line consistent-this 149 url = $.trim( embedLinkView.model.get( 'url' ) ); 152 150 153 151 if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) { 154 152 embedLinkView.dfd.abort(); … … 167 165 }; 168 166 169 167 urlParser = document.createElement( 'a' ); 170 urlParser.href = embedLinkView.model.get( 'url' );168 urlParser.href = url; 171 169 matches = urlParser.pathname.toLowerCase().match( /\.(\w+)$/ ); 172 170 if ( matches ) { 173 171 fileExt = matches[1]; … … 184 182 embedLinkView.dfd = $.ajax({ 185 183 url: wp.media.view.settings.oEmbedProxyUrl, 186 184 data: { 187 url: embedLinkView.model.get( 'url' ),185 url: url, 188 186 maxwidth: embedLinkView.model.get( 'width' ), 189 187 maxheight: embedLinkView.model.get( 'height' ), 190 188 _wpnonce: wp.media.view.settings.nonce.wpRestApi, … … 779 777 mediaFramePropToModelPropMap[ fieldSchema.media_prop || modelProp ] = modelProp; 780 778 }); 781 779 780 // Trim whitespace from url since it causes problems with oembeds. 781 if ( mediaFrameProps.url ) { 782 mediaFrameProps.url = $.trim( mediaFrameProps.url ); 783 } 784 782 785 _.each( mediaFrameProps, function( value, mediaProp ) { 783 786 var propName = mediaFramePropToModelPropMap[ mediaProp ] || mediaProp; 784 787 if ( control.model.schema[ propName ] ) { -
src/wp-includes/media.php
3424 3424 'audio' => ( $show_audio_playlist ) ? 1 : 0, 3425 3425 'video' => ( $show_video_playlist ) ? 1 : 0, 3426 3426 ), 3427 'oEmbedProxyUrl' => rest_url( 'oembed/1.0/proxy'),3427 'oEmbedProxyUrl' => preg_replace( '#^\w+:#', '', rest_url( 'oembed/1.0/proxy' ) ), 3428 3428 'embedExts' => $exts, 3429 3429 'embedMimes' => $ext_mimes, 3430 3430 'contentWidth' => $content_width, -
tests/qunit/wp-admin/js/widgets/test-media-video-widget.js
28 28 equal( mappedProps.preload, 'meta', 'mapModelToMediaFrameProps should set preload' ); 29 29 30 30 // Test mapMediaToModelProps(). 31 mappedProps = videoWidgetControlInstance.mapMediaToModelProps( { loop: false, preload: 'meta', url: testVideoUrl , title: 'random movie file title' } );31 mappedProps = videoWidgetControlInstance.mapMediaToModelProps( { loop: false, preload: 'meta', url: testVideoUrl + ' ', title: 'random movie file title' } ); 32 32 equal( mappedProps.title, undefined, 'mapMediaToModelProps should ignore title inputs' ); 33 33 equal( mappedProps.loop, false, 'mapMediaToModelProps should set loop' ); 34 34 equal( mappedProps.preload, 'meta', 'mapMediaToModelProps should set preload' ); 35 equal( mappedProps.url, testVideoUrl, 'mapMediaToModelProps should trim whitespace from urls' ); 35 36 }); 36 37 37 38 test( 'video widget control renderPreview', function( assert ) {