mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-16 20:35:09 +00:00
Merge "Add marker parameter to image requests coming from MediaViewer"
This commit is contained in:
commit
7638a878f9
|
@ -109,6 +109,14 @@ if ( !isset( $wgMediaViewerEnableByDefaultForAnonymous ) ) {
|
|||
$wgMediaViewerEnableByDefaultForAnonymous = $wgMediaViewerEnableByDefault;
|
||||
}
|
||||
|
||||
if ( !isset( $wgMediaViewerImageQueryParameter ) ) {
|
||||
/**
|
||||
* If set, adds a query parameter to image requests made by Media Viewer
|
||||
* @var string|bool
|
||||
*/
|
||||
$wgMediaViewerImageQueryParameter = false;
|
||||
}
|
||||
|
||||
$wgMessagesDirs['MultimediaViewer'] = __DIR__ . '/i18n';
|
||||
$wgExtensionMessagesFiles['MultimediaViewer'] = __DIR__ . '/MultimediaViewer.i18n.php';
|
||||
|
||||
|
@ -300,6 +308,7 @@ $wgResourceModules += array(
|
|||
|
||||
'dependencies' => array(
|
||||
'mediawiki.Title',
|
||||
'mediawiki.Uri',
|
||||
'mmv.model',
|
||||
'mmv.model.IwTitle',
|
||||
'mmv.model.Image',
|
||||
|
|
|
@ -142,7 +142,7 @@ class MultimediaViewerHooks {
|
|||
global $wgMediaViewerActionLoggingSamplingFactorMap, $wgNetworkPerformanceSamplingFactor,
|
||||
$wgMediaViewerDurationLoggingSamplingFactor, $wgMediaViewerDurationLoggingLoggedinSamplingFactor,
|
||||
$wgMediaViewerAttributionLoggingSamplingFactor, $wgMediaViewerDimensionLoggingSamplingFactor,
|
||||
$wgMediaViewerIsInBeta, $wgMediaViewerUseThumbnailGuessing;
|
||||
$wgMediaViewerIsInBeta, $wgMediaViewerUseThumbnailGuessing, $wgMediaViewerImageQueryParameter;
|
||||
$vars['wgMultimediaViewer'] = array(
|
||||
'infoLink' => self::$infoLink,
|
||||
'discussionLink' => self::$discussionLink,
|
||||
|
@ -154,6 +154,7 @@ class MultimediaViewerHooks {
|
|||
'actionLoggingSamplingFactorMap' => $wgMediaViewerActionLoggingSamplingFactorMap,
|
||||
'attributionSamplingFactor' => $wgMediaViewerAttributionLoggingSamplingFactor,
|
||||
'dimensionSamplingFactor' => $wgMediaViewerDimensionLoggingSamplingFactor,
|
||||
'imageQueryParameter' => $wgMediaViewerImageQueryParameter,
|
||||
'tooltipDelay' => 1000,
|
||||
);
|
||||
$vars['wgMediaViewer'] = true;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
* @property {mw.mmv.provider.Image}
|
||||
* @private
|
||||
*/
|
||||
this.imageProvider = new mw.mmv.provider.Image();
|
||||
this.imageProvider = new mw.mmv.provider.Image( mw.config.get( 'wgMultimediaViewer' ).imageQueryParameter );
|
||||
|
||||
/**
|
||||
* @property {mw.mmv.provider.ImageInfo}
|
||||
|
|
|
@ -20,14 +20,18 @@
|
|||
/**
|
||||
* Loads an image.
|
||||
* @class mw.mmv.provider.Image
|
||||
* @constructor
|
||||
* @param {string} imageQueryParameter When defined, is a query parameter to add to every image request
|
||||
*/
|
||||
function Image() {
|
||||
function Image( imageQueryParameter ) {
|
||||
/**
|
||||
* @property {mw.mmv.logging.Performance}
|
||||
* @private
|
||||
*/
|
||||
this.performance = new mw.mmv.logging.Performance();
|
||||
|
||||
this.imageQueryParameter = imageQueryParameter;
|
||||
|
||||
/**
|
||||
* AJAX call cache.
|
||||
* @property {Object.<string, jQuery.Promise>} cache
|
||||
|
@ -47,8 +51,16 @@
|
|||
Image.prototype.get = function ( url ) {
|
||||
var provider = this,
|
||||
cacheKey = url,
|
||||
extraParam = {},
|
||||
start,
|
||||
rawGet;
|
||||
rawGet,
|
||||
uri;
|
||||
|
||||
if ( this.imageQueryParameter ) {
|
||||
uri = new mw.Uri( url );
|
||||
extraParam[ this.imageQueryParameter ] = null;
|
||||
url = uri.extend( extraParam ).toString();
|
||||
}
|
||||
|
||||
if ( !this.cache[cacheKey] ) {
|
||||
if ( this.imagePreloadingSupported() ) {
|
||||
|
|
|
@ -200,4 +200,17 @@
|
|||
QUnit.start();
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( 'imageQueryParameter', 1, function ( assert ) {
|
||||
var imageProvider = new mw.mmv.provider.Image( 'foo' );
|
||||
|
||||
imageProvider.imagePreloadingSupported = function () { return false; };
|
||||
imageProvider.rawGet = function () { return $.Deferred().resolve(); };
|
||||
|
||||
imageProvider.performance.recordEntry = function ( type, total, url ) {
|
||||
assert.strictEqual( url, 'http://www.wikipedia.org/?foo', 'Extra parameter added' );
|
||||
};
|
||||
|
||||
imageProvider.get( 'http://www.wikipedia.org/' );
|
||||
} );
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
Loading…
Reference in a new issue