mediawiki-extensions-Visual.../modules/ve-mw/init/ve.init.mw.ImageInfoCache.js
David Lynch 7486f74c6f MWMediaDialog: Only cache relevant information
Trim the cached image data from the media dialog down so that it only caches
the same information that would have been fetched for a non-uploaded image.
Consistency!

Bug: T126081
Change-Id: I0f057c111b66f29c6360e27f97256384f5320b75
2016-02-29 10:16:34 -06:00

53 lines
1.1 KiB
JavaScript

/*!
* VisualEditor MediaWiki Initialization ImageInfoCache class.
*
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Get information about images.
*
* @class
* @extends ve.init.mw.ApiResponseCache
* @constructor
*/
ve.init.mw.ImageInfoCache = function VeInitMwImageInfoCache() {
ve.init.mw.ImageInfoCache.super.call( this );
};
/* Inheritance */
OO.inheritClass( ve.init.mw.ImageInfoCache, ve.init.mw.ApiResponseCache );
/* Static methods */
/**
* @inheritdoc
*/
ve.init.mw.ImageInfoCache.static.processPage = function ( page ) {
if ( page.imageinfo ) {
return page.imageinfo[ 0 ];
}
};
/* Methods */
/**
* @inheritdoc
*/
ve.init.mw.ImageInfoCache.prototype.getRequestPromise = function ( subqueue ) {
// If you change what `iiprop`s are being fetched, update
// ve.ui.MWMediaDialog to add the same ones to the cache.
return new mw.Api().get(
{
action: 'query',
prop: 'imageinfo',
indexpageids: '1',
iiprop: 'size|mediatype',
titles: subqueue.join( '|' )
},
{ type: 'POST' }
);
};