Make WordPress Core

Changeset 23048


Ignore:
Timestamp:
12/04/2012 11:07:41 PM (12 years ago)
Author:
ryan
Message:

When inserting an image From URL, show the fields only if it looks like we have a valid image.

Props koopersmith
fixes #22740

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/media-views.js

    r23041 r23048  
    762762                image = new Image();
    763763
     764            // Try to load the image and find its width/height.
    764765            image.onload = function() {
    765766                if ( state !== frame.state() || url !== state.props.get('url') )
     
    774775
    775776            image.src = url;
     777
     778            // Check if the URL looks like an image; skew toward success.
     779            url = url.replace( /([?|#].*)$/, '' );
     780            if ( /\.(png|jpe?g|gif)$/i.test( url ) )
     781                attributes.type = 'image';
    776782        },
    777783
Note: See TracChangeset for help on using the changeset viewer.