扩展:共享资源元数据
CommonsMetadata 发行状态: 稳定版 |
|
---|---|
实现 | API |
描述 | 尝试从共享资源页面中提取元数据 |
作者 | Brian Wolff (bawolff留言) |
兼容性政策 | 快照跟随MediaWiki发布。 master分支不向后兼容。 |
MediaWiki | 1.25+ |
PHP | 5.4+ |
数据库更改 | 否 |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | |
|
|
季度下載量 | 75 (Ranked 69th) |
正在使用的公开wiki数 | 1,055 (Ranked 247th) |
前往translatewiki.net翻譯CommonsMetadata扩展 | |
問題 | 开启的任务 · 报告错误 |
共享资源元数据扩展是一个从维基共享资源中提取元数据的尝试,但也可以用于其它维基媒体项目。 它基于图片描述中的模版和分类来添加一些额外信息到imageinfo API中。 它被许多扩展和工具(例如 Extension:MultimediaViewer ,Extension:VisualEditor ,Extension:移动版前端 ,移动内容服务(MCS))用来提供更好的边框或图像选择对话框。
目前的这个扩展是一个暂时的解决方案,它最终会被维基共享资源中的维基数据取代。
安裝
- 下载文件,并将解压后的
CommonsMetadata
文件夹移动到extensions/
目录中。
开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CommonsMetadata - 将下列代码放置在您的LocalSettings.php 的底部:
wfLoadExtension( 'CommonsMetadata' );
- 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
动机与设计选择
参见mailarchive:wikitech-l/2013-August/071593.html
此扩展的假想如下。
- At some point in the future, Wikidata will take over handling metadata at Commons. To avoid disruptive changes, which will soon need to be changed again, the extension should work with common metadata as it currently is (so not introducing new parser functions). Hence, screen scraping.
- The content of many of the fields on a commons description page includes rich formatting (In particular: Links, italics, bold. In some cases, more complex things like embedded images)
- As a result, the extension outputs parsed html (wikitext sucks, plain text doesn't capture the data)
- Furthermore, the data tends to be formatted for human display rather than (for example) machine-formatted dates. When the date field says something like "circa 1600s", it's hard to convert that to a precise date (many examples can be).
- To carry that forward, also apply formatting to EXIF metadata, which is controlled on the wiki (For example, commons links the camera name to a Wikipedia article)
- If we can't extract info from the description page, but the file has the author tagged in EXIF/XMP/iptc metadata, we should use that as a fallback.
- Ideally, such a system would be as commons-specific as possible, with the commons and non-commons parts separated.
- Commons description pages have multilingual descriptions. Lots of users probably want one language.
- This implementation applies per language conventions to dates and things. Additionally, for explicitly multi-lingual fields (description), there is an option to return all or just a single language. Even in single language mode, some things are still language-specific (like the thousands separator on numbers)
Configuration
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. |
测试
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).
用法
Use the imageinfo API, and include extmetadata
as an image info property specified via iiprop
.
示例用法:
View this example in the API sandbox:
返回的数据
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.
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 this table, without the
restriction-
prefix). See also the 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).
参见
- 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.
此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
此扩展在以下wiki农场/托管网站和/或软件包中提供: 這不是一份權威名單。 即使某些wiki农场/托管网站和/或软件包未在这里列出,它们也可能提供此扩展。 请检查你的wiki农场/托管网站或软件包以确认提供情况。 |
- Stable extensions/zh
- API extensions/zh
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- ContentAlterParserOutput extensions/zh
- GetExtendedMetadata extensions/zh
- SkinAfterBottomScripts extensions/zh
- ValidateExtendedMetadataCache extensions/zh
- All extensions/zh
- Extensions used on Wikimedia/zh
- Extensions included in Canasta/zh
- Extensions included in Miraheze/zh
- Extensions included in WikiForge/zh
- Metadata/zh
- Data extraction extensions/zh