From 6114f46a487274cbe14789c0f66468cfd0118ae8 Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Thu, 30 Jul 2015 13:52:38 -0500 Subject: [PATCH] Add getImageInfo to mw.Upload Just a little shortcut and so you don't need to rely on the promises. Bug: T107460 Change-Id: I1e36f3cd8cb6b50ec5db6d77512ce03cd98a2caf --- resources/src/mediawiki/mediawiki.Upload.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/resources/src/mediawiki/mediawiki.Upload.js b/resources/src/mediawiki/mediawiki.Upload.js index 197ea6fc6a..b8425456a3 100644 --- a/resources/src/mediawiki/mediawiki.Upload.js +++ b/resources/src/mediawiki/mediawiki.Upload.js @@ -21,6 +21,8 @@ this.filename = null; this.file = null; this.state = Upload.State.NEW; + + this.imageinfo = undefined; } UP = Upload.prototype; @@ -146,6 +148,16 @@ return this.state; }; + /** + * Get the imageinfo object for the finished upload. + * Only available once the upload is finished! Don't try to get it + * beforehand. + * @return {Object|undefined} + */ + UP.getImageInfo = function () { + return this.imageinfo; + }; + /** * Upload the file directly. * @return {jQuery.Promise} @@ -170,6 +182,7 @@ text: this.text } ).then( function ( result ) { upload.state = Upload.State.UPLOADED; + upload.imageinfo = result.upload.imageinfo; return result; }, function () { upload.state = Upload.State.ERROR; -- 2.20.1