Make WordPress Core

Changeset 40772


Ignore:
Timestamp:
05/17/2017 01:58:16 AM (7 years ago)
Author:
westonruter
Message:

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.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/widgets/media-widgets.js

    r40660 r40772  
    143143                     * Fetch media.
    144144                     *
    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/40450
    148145                     * @returns {void}
    149146                     */
     
    153150                        if ( embedLinkView.dfd && 'pending' === embedLinkView.dfd.state() ) {
    154151                            embedLinkView.dfd.abort();
     152                        }
     153
     154                        // Abort if the URL field was emptied out.
     155                        if ( ! embedLinkView.model.get( 'url' ) ) {
     156                            embedLinkView.setErrorNotice( '' );
     157                            return;
    155158                        }
    156159
  • trunk/src/wp-includes/js/media-views.js

    r40628 r40772  
    47404740
    47414741    url: function( event ) {
    4742         this.model.set( 'url', event.target.value );
     4742        this.model.set( 'url', $.trim( event.target.value ) );
    47434743    },
    47444744
  • trunk/src/wp-includes/js/media/views/embed/url.js

    r33337 r40772  
    6161
    6262    url: function( event ) {
    63         this.model.set( 'url', event.target.value );
     63        this.model.set( 'url', $.trim( event.target.value ) );
    6464    },
    6565
Note: See TracChangeset for help on using the changeset viewer.