Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/init/apiresponsecache/ve.init.mw.ImageInfoCache.js

raw symbols SCIP
1 /*!
2 * VisualEditor MediaWiki Initialization ImageInfoCache class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * Get information about images.
10 *
11 * @class
12 * @extends ve.init.mw.ApiResponseCache
13 * @constructor
14 * @param {mw.Api} [api]
15 */
16 ve.init.mw.ImageInfoCache = function VeInitMwImageInfoCache() {
17 // Parent constructor
18 ve.init.mw.ImageInfoCache.super.apply( this, arguments );
19 };
20
21 /* Inheritance */
22
23 OO.inheritClass( ve.init.mw.ImageInfoCache, ve.init.mw.ApiResponseCache );
24
25 /* Static methods */
26
27 /**
28 * @inheritdoc
29 */
30 ve.init.mw.ImageInfoCache.static.processPage = function ( page ) {
31 if ( page.imageinfo ) {
32 return page.imageinfo[ 0 ];
33 } else if ( 'missing' in page ) {
34 return { missing: true };
35 }
36 };
37
38 /* Methods */
39
40 /**
41 * @inheritdoc
42 */
43 ve.init.mw.ImageInfoCache.prototype.getRequestPromise = function ( subqueue ) {
44 // If you change what `iiprop`s are being fetched, update
45 // ve.ui.MWMediaDialog to add the same ones to the cache.
46 return this.api.get(
47 {
48 action: 'query',
49 prop: 'imageinfo',
50 indexpageids: '1',
51 iiprop: 'size|mediatype',
52 titles: subqueue
53 },
54 { type: 'POST' }
55 );
56 };