When inserting an image From URL, show the fields only if it looks like we have a valid image.
Props koopersmith fixes #22740 git-svn-id: http://core.svn.wordpress.org/trunk@23048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d3b24a0e15
commit
51db7de93b
|
@ -761,6 +761,7 @@
|
|||
url = this.props.get('url'),
|
||||
image = new Image();
|
||||
|
||||
// Try to load the image and find its width/height.
|
||||
image.onload = function() {
|
||||
if ( state !== frame.state() || url !== state.props.get('url') )
|
||||
return;
|
||||
|
@ -773,6 +774,11 @@
|
|||
};
|
||||
|
||||
image.src = url;
|
||||
|
||||
// Check if the URL looks like an image; skew toward success.
|
||||
url = url.replace( /([?|#].*)$/, '' );
|
||||
if ( /\.(png|jpe?g|gif)$/i.test( url ) )
|
||||
attributes.type = 'image';
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
|
|
Loading…
Reference in New Issue