From MediaWiki.org
Jump to: navigation, search

MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png

Release status:Extension status stable

Screenshot of the GlobalUsage Extension.jpg
ImplementationTemplate:Extension#type Special page, API
DescriptionTemplate:Extension#description Allows to view the global usage of images in a wiki farm with shared image repository
Author(s)Template:Extension#username Bryan Tong Minh (Bryantalk)
Latest versionTemplate:Extension#version 2.2.0
MediaWikiTemplate:Extension#mediawiki 1.28+
Database changesTemplate:Extension#needs-updatephp Yes
LicenseTemplate:Extension#license MIT License
Hooks usedTemplate:Extension#hook

Translate the GlobalUsage extension if it is available at translatewiki.net

Check usage and version matrix.


Open tasks · Report a bug

The GlobalUsage extension allows to view the global usage of images in a wiki farm with shared image repository. It adds Special:GlobalUsage as well as a list of pages that include the image on image description pages.


  • Download and place the file(s) in a directory called GlobalUsage in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'GlobalUsage' );
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • In LocalSettings, set $wgGlobalUsageDatabase to the identifier of the wiki where the GlobalUsage data is located (usually the database name). It should be something understandable to wfGetDB. Example: $wgGlobalUsageDatabase = 'commonswiki';
    At present, this can NOT be a database name of a wiki, but must be a name given in a load balancer configuration: Manual:$wgLBFactoryConf, a complex and largely undocumented configuration structure used by the WMF and Wikia. For a normal mediawiki setup using multiple databases configuring and maintaining this data structures implies significant difficulties.
  • Run refreshGlobalimagelinks.php on all wikis in your farm. This will take a long time, but only needs to be done once when installing the extension. php extensions/GlobalUsage/refreshGlobalimagelinks.php --pages=existing,nonexisting
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'GlobalUsage' );, you need to use:

require_once "$IP/extensions/GlobalUsage/GlobalUsage.php";


To get the right links to the sites and pages under "Global file usage" one of the following conditions must be met

  • the databases follow Wikimedia's database naming convention: languagesuffix like 'enwiki', 'commonswiki' etc.
  • a site configuration object ($wgConf) is created with an array for $wgCanonicalServer and $wgArticlePath for all wikis
  • the extension is patched to use the information in the interwiki table.


Extension:GlobalUsage includes an API extension that allows bots and other programs to query the global usage of a file. For example, this query on Wikimedia Commons returns global uses of File:Example.jpg:

By default this returns only 10 results. The next 10 results can be retrieved using the gucontinue parameter included in the result above:

The number of results returned is set with the gulimit parameter. The guprop parameter sets which properties to retrieve. The gufilterlocal parameter, when set to 1, will exclude uses on the same wiki as the file (e.g. on Commons). The following query retrieves all properties and up to 100 results, excluding local uses: