In Media Grid, don't immediately load full size images if the requested size passed to wp.media.view.Attachment.imageSize() does not exist, look for other suitable sizes.

Fixes #30861.


git-svn-id: https://develop.svn.wordpress.org/trunk@31039 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-01-03 21:31:23 +00:00
parent 3fe38d959a
commit 6d858cc6e2

View File

@@ -5430,21 +5430,33 @@
* @returns {Object}
*/
imageSize: function( size ) {
var sizes = this.model.get('sizes');
var sizes = this.model.get('sizes'), matched = false;
size = size || 'medium';
// Use the provided image size if possible.
if ( sizes && sizes[ size ] ) {
return _.clone( sizes[ size ] );
} else {
return {
url: this.model.get('url'),
width: this.model.get('width'),
height: this.model.get('height'),
orientation: this.model.get('orientation')
};
if ( sizes ) {
if ( sizes[ size ] ) {
matched = sizes[ size ];
} else if ( sizes.large ) {
matched = sizes.large;
} else if ( sizes.thumbnail ) {
matched = sizes.thumbnail;
} else if ( sizes.full ) {
matched = sizes.full;
}
if ( matched ) {
return _.clone( matched );
}
}
return {
url: this.model.get('url'),
width: this.model.get('width'),
height: this.model.get('height'),
orientation: this.model.get('orientation')
};
},
/**
* @param {Object} event