Extension:CommonsMetadata
![]() Release status: stable |
|
---|---|
Implementation | API |
Description | Attempts at extracting metadata from commons pages |
Author(s) | Brian Wolff (bawolfftalk) |
Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
MediaWiki | 1.25+ |
PHP | 5.4+ |
Database changes | No |
License | GNU General Public License 2.0 or later |
Download | |
|
|
Quarterly downloads | 74 (Ranked 64th) |
Public wikis using | 1,055 (Ranked 247th) |
Translate the CommonsMetadata extension if it is available at translatewiki.net | |
Issues | Report a bug |
The CommonsMetadata extension is an attempt at extracting metadata from Wikimedia Commons pages but is also available at all other Wikimedia projects. It adds some extra information to the imageinfo API, based on templates and categories in the image description. It is used by several extensions/tools (such as Extension:MultimediaViewer , Extension:VisualEditor , Extension:MobileFrontend , Mobile-Content-Service (MCS)) to provide better lightboxes or image selection dialogs.
The extension in its current form is intended to be a temporary solution, eventually replaced by Wikidata on Commons.
Installation
[edit]- Download and move the extracted
CommonsMetadata
folder to yourextensions/
directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CommonsMetadata - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'CommonsMetadata' );
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Motivation & design choices
[edit]See
Configuration
[edit]
parameter | default | description |
---|---|---|
$wgCommonsMetadataSetTrackingCategories
|
false
|
Add the following tracking categories to file pages when the corresponding information is not provided either via templates on the file page of (for some of these) EXIF metadata:
|
$wgCommonsMetadataPublicDomainPageUrl
|
https://commons.wikimedia.org/wiki/Help:Public_domain
|
Link used for 'license' attribute in schema.org markup for files in the public domain. |
$wgCommonsMetadataForceRecalculate
|
false
|
Force calculation of metadata even when the image is from a foreign repository that would provide it. This is meant for local development. |
Testing
[edit]When testing with remote images (e.g. Commons images if you have enabled $wgUseInstantCommons
), you can set $wgCommonsMetadataForceRecalculate = true;
to force CommonsMetadata to parse the description page of the image and extract the metadata (normally, if the remote repository had CommonsMetadata installed as well, it would just copy the API output from there).
Usage
[edit]Use the imageinfo API, and include extmetadata
as an image info property specified via iiprop
.
Example
[edit]View this example in the API sandbox:
Returned data
[edit]The extension currently provides the following items in the extmetadata
field of the response (the field names were chosen, where possible, to follow the IPTC-IIM format used in EXIF headers):
Data based on machine-readable data in the Information template:
- ImageDescription - image description
- Artist - author name (might contain complex HTML, multiple authors, etc)
- Credit - source
- DateTimeOriginal - time of creation (space-separated ISO 8601 timestamp whenever possible, but can be any other textual description of a date, possibly with HTML mixed in)
- ObjectName - title (for a book/painting; otherwise just the file name)
- Permission - contents of the Permission field of the template. It can be a lot of things (license template, OTRS ID, details on how to attribute...)
- AuthorCount - the number of templates with authors (e.g., Book, Photograph...). The number of actual authors might be higher if a template describes multiple authors in a single string.
Data based on machine-readable data in the Location template:
- GPSLatitude - latitude
- GPSLongitude - longitude
- GPSMapDatum - coordinate type (only
WGS-84
supported for now)
Data based on machine-readable data in the license template:
- LicenseShortName - short human-readable license name
- LicenseUrl
- UsageTerms
- Copyrighted -
True
orFalse
(for public domain images)
For multi-licensed images, these values are currently unreliable.
- Attribution - custom attribution that should replace Artist + Credit (can also originate from the Information template)
- AttributionRequired - booleanish (phab:T86726), tells whether there is a legal requirement to attribute
- NonFree - booleanish, true means the image is not under a free license. (Used for non-Commons images only.)
Other data:
- CommonsMedadataExtension - contains the metadata parser version number; mostly for internal use
- License - a best guess at the license of the image (mostly for internal use by MediaViewer, might change; LicenseShortName is probably more reliable)
- Categories - a
|
-separated list of the categories of the image. - Assessments - a
|
-separated list of the assessments of the image (currently five values are supported: quality, valued). Based on parsing category names, probably won't work for images not hosted on Commons. - Restrictions - reuse restrictions such as trademarks or personality rights; an array of keywords (the class names from restrict-* icons in MediaViewer.
- DeletionReason - if set, the template is being considered for deletion. (Based on the nuke template, probably not reliable outside Commons.) It contains a deletion reason, but it is phrased to be applicable for a log entry, so it might be misleading (e.g. past tense when actually it is not yet decided whether the image will be deleted).
See also
[edit]- How to add metadata
- Manual:File metadata handling
- Extension:MultimediaViewer - currently the main user of the information provided by CommonsMetadata.
- Request for comment on handling image information
- Template detection on local wikis with locally uploaded files – Describes how to prepare the templates for fetching metadata and thus displaying them when using the MultimediaViewer extension.
- Extension:CommonsMetadata/info template for 3rd-party wikis
![]() | This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
- Stable extensions
- API extensions
- GPL licensed extensions
- Extensions in Wikimedia version control
- ContentAlterParserOutput extensions
- GetExtendedMetadata extensions
- SkinAfterBottomScripts extensions
- ValidateExtendedMetadataCache extensions
- All extensions
- Extensions used on Wikimedia
- Extensions included in Canasta
- Extensions included in Miraheze
- Extensions included in WikiForge
- Metadata
- Data extraction extensions