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: https://develop.svn.wordpress.org/trunk@23048 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2e35cea2fa
commit
e13e333569
|
@ -761,6 +761,7 @@
|
||||||
url = this.props.get('url'),
|
url = this.props.get('url'),
|
||||||
image = new Image();
|
image = new Image();
|
||||||
|
|
||||||
|
// Try to load the image and find its width/height.
|
||||||
image.onload = function() {
|
image.onload = function() {
|
||||||
if ( state !== frame.state() || url !== state.props.get('url') )
|
if ( state !== frame.state() || url !== state.props.get('url') )
|
||||||
return;
|
return;
|
||||||
|
@ -773,6 +774,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
image.src = url;
|
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() {
|
refresh: function() {
|
||||||
|
|
Loading…
Reference in New Issue