Media: Trim whitespace in URLs provided for external embeds.
Also avoid showing error notice in media widget when URL field is empty. Props timmydcrawford, westonruter. Fixes #40771. git-svn-id: https://develop.svn.wordpress.org/trunk@40772 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4dc737ca8e
commit
2dd4bc7388
|
@ -142,9 +142,6 @@ wp.mediaWidgets = ( function( $ ) {
|
|||
/**
|
||||
* Fetch media.
|
||||
*
|
||||
* This is a TEMPORARY measure until the WP API supports an oEmbed proxy endpoint. See #40450.
|
||||
*
|
||||
* @see https://core.trac.wordpress.org/ticket/40450
|
||||
* @returns {void}
|
||||
*/
|
||||
fetch: function() {
|
||||
|
@ -154,6 +151,12 @@ wp.mediaWidgets = ( function( $ ) {
|
|||
embedLinkView.dfd.abort();
|
||||
}
|
||||
|
||||
// Abort if the URL field was emptied out.
|
||||
if ( ! embedLinkView.model.get( 'url' ) ) {
|
||||
embedLinkView.setErrorNotice( '' );
|
||||
return;
|
||||
}
|
||||
|
||||
fetchSuccess = function( response ) {
|
||||
embedLinkView.renderoEmbed({
|
||||
data: {
|
||||
|
|
|
@ -4739,7 +4739,7 @@ EmbedUrl = View.extend({
|
|||
},
|
||||
|
||||
url: function( event ) {
|
||||
this.model.set( 'url', event.target.value );
|
||||
this.model.set( 'url', $.trim( event.target.value ) );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,7 @@ EmbedUrl = View.extend({
|
|||
},
|
||||
|
||||
url: function( event ) {
|
||||
this.model.set( 'url', event.target.value );
|
||||
this.model.set( 'url', $.trim( event.target.value ) );
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue