From 42487a5b23b714160da543205c211580130fa464 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 11 May 2017 21:23:50 +0000 Subject: [PATCH] Widgets: Utilize WP REST API oEmbed proxy endpoint in media widgets. Props timmydcrawford. See #32417, #40450. git-svn-id: https://develop.svn.wordpress.org/trunk@40641 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/widgets/media-video-widget.js | 10 ++++++---- src/wp-admin/js/widgets/media-widgets.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/js/widgets/media-video-widget.js b/src/wp-admin/js/widgets/media-video-widget.js index 4ad17871fa..8c5563164d 100644 --- a/src/wp-admin/js/widgets/media-video-widget.js +++ b/src/wp-admin/js/widgets/media-video-widget.js @@ -111,15 +111,17 @@ } control.fetchEmbedDfd = jQuery.ajax({ - url: 'https://noembed.com/embed', + url: wp.media.view.settings.oEmbedProxyUrl, data: { url: control.model.get( 'url' ), maxwidth: control.model.get( 'width' ), - maxheight: control.model.get( 'height' ) + maxheight: control.model.get( 'height' ), + _wpnonce: wp.media.view.settings.nonce.wpRestApi, + discover: false }, type: 'GET', - crossDomain: true, - dataType: 'json' + dataType: 'json', + context: control }); control.fetchEmbedDfd.done( function( response ) { diff --git a/src/wp-admin/js/widgets/media-widgets.js b/src/wp-admin/js/widgets/media-widgets.js index 4ce0f3d850..c45e9ee954 100644 --- a/src/wp-admin/js/widgets/media-widgets.js +++ b/src/wp-admin/js/widgets/media-widgets.js @@ -182,15 +182,17 @@ wp.mediaWidgets = ( function( $ ) { } embedLinkView.dfd = $.ajax({ - url: 'https://noembed.com/embed', // @todo Replace with core proxy endpoint once committed. + url: wp.media.view.settings.oEmbedProxyUrl, data: { url: embedLinkView.model.get( 'url' ), maxwidth: embedLinkView.model.get( 'width' ), - maxheight: embedLinkView.model.get( 'height' ) + maxheight: embedLinkView.model.get( 'height' ), + _wpnonce: wp.media.view.settings.nonce.wpRestApi, + discover: false }, type: 'GET', - crossDomain: true, - dataType: 'json' + dataType: 'json', + context: embedLinkView }); embedLinkView.dfd.done( function( response ) {