Jump to content

Extension:CommonsMetadata/info template for 3rd-party wikis

From mediawiki.org

CommonsMetadata is written to parse the highly complex information templates used on Wikimedia Commons. If you want to use it on a non-Wikimedia wiki for local files, here is a simple template that should be compatible:

<table class="toccolours vevent mw-content-en" style="width: 100%; direction: ltr;" cellpadding="4">
<!-- Description -->
{{#if:{{{description|{{{Description|}}}}}}|
<tr style="vertical-align: top">
<td id="fileinfotpl_desc" class="fileinfo-paramfield">Description<span class="summary fn" style="display:none">{{PAGENAME}}</span><!-- required for hCalendar and hProduct microformat; though hMedia would be more appropriate --></td>
<td class="description">
{{{description|{{{Description|}}}}}}
</td>
</tr>
}}
<!-- Date -->
{{#if:{{{date|{{{Date|}}}}}}|
<tr style="vertical-align: top">
<td id="fileinfotpl_date" class="fileinfo-paramfield">Date</td>
<td>{{{date|{{{Date|}}}}}}</td>
</tr>
}}
<!-- Source -->
{{#if:{{{source|{{{Source|}}}}}}|
<tr style="vertical-align: top">
<td id="fileinfotpl_src" class="fileinfo-paramfield">Source</td>
<td>{{{source|{{{Source|}}}}}}</td>
</tr>
}}
<!-- Author -->
{{#if:{{{author|{{{Author|}}}}}}|
<tr style="vertical-align: top">
<td id="fileinfotpl_aut" class="fileinfo-paramfield">Author</td>
<td>{{{author|{{{Author|}}}}}}</td>
</tr>
}}
<!-- License -->
{{#if:{{{license|{{{License|}}}}}}|
<tr style="vertical-align: top">
<td class="fileinfo-paramfield">License</td>
<td><span class="licensetpl"><span class="licensetpl_short>{{{license|{{{License|}}}}}}</span></span></td>
</tr>
}}
</table>

Save it to the "Template:Information" page and use it like this:

{{Information
|description = ... image description ...
|author = ... author name ...
|source = ... source ...
|date = ... date of creation ...
|license = ... short name of license (e.g. "CC-BY-SA-3.0") ...
}}

All fields are optional.

Note that the template's name does not matter. What matters are the classes used in the table elements. For this to work, you must use Extension:CommonsMetadata .