Difference between revisions of "Template:FileCaption"

From WikiCorporates
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
−
{{#if:{{{caption|}}}<!--
+
{{#if:{{{caption|}}}<!-- has caption, so wrap in a div
 
-->|<div style="<!--
 
-->|<div style="<!--
 
-->{{#switch:{{{float}}}<!--
 
-->{{#switch:{{{float}}}<!--
−
-->|none={{#if:{{{ml|}}}|margin-left:{{{ml}}}em;}} {{#if:{{{mr|}}}|margin-right:{{{mr}}}em;}}<!--
+
-->|none={{#if:{{{ml|}}}| margin-left:{{{ml}}}em;}} {{#if:{{{mr|}}}| margin-right:{{{mr}}}em;}}<!--
−
-->|left=float:left; {{#if:{{{mr|}}}|margin-right:{{{mr}}}em;| margin-right=0.5em;}} {{#if:{{{ml|}}}|margin-left:{{{ml}}}em;}}<!--
+
-->|left=float:left; {{#if:{{{mr|}}}| margin-right:{{{mr}}}em;| margin-right=0.5em;}} {{#if:{{{ml|}}}| margin-left:{{{ml}}}em;}}<!--
−
-->|#default=float:right; {{#if:{{{ml|}}}|margin-left:{{{ml}}}em;|margin-left:0.5em;}} {{#if:{{{mr|}}}|margin-right:{{{mr}}}em; }}<!--
+
-->|#default=float:right; {{#if:{{{ml|}}}| margin-left:{{{ml}}}em;| margin-left:0.5em;}} {{#if:{{{mr|}}}| margin-right:{{{mr}}}em; }}<!--
−
-->}}<!-- else no float
+
-->}}<!--
−
-->{{#if:{{{border|}}}|border:thin solid {{{border}}};}} text-align:center; font-size:80%; width:{{{2}}}px;"><!--
+
-->{{#if:{{{border|}}}| border:thin solid {{{border}}};}}<!--
 +
-->{{#if:{{{pad|}}}| padding:{{{pad}}}em;}} text-align:center; font-size:80%; width:{{{2}}}px;"><!--
 
-->[[File:{{{1}}}|{{{2}}}x{{{3}}}px]]{{{caption}}}</div><!--
 
-->[[File:{{{1}}}|{{{2}}}x{{{3}}}px]]{{{caption}}}</div><!--
−
-->|<span style="<!--
+
-->|<span style="<!-- no caption; wrap in a span so can be an inline img
 
-->{{#switch:{{{float}}}<!--
 
-->{{#switch:{{{float}}}<!--
−
-->|none={{#if:{{{ml|}}}|margin-left:{{{ml}}}em;}} {{#if:{{{mr|}}}|margin-right:{{{mr}}}em;}}<!--
+
-->|none={{#if:{{{ml|}}}| margin-left:{{{ml}}}em;}} {{#if:{{{mr|}}}| margin-right:{{{mr}}}em;}}<!--
−
-->|left=float:left; {{#if:{{{mr|}}}|margin-right:{{{mr}}}em;| margin-right=0.5em;}} {{#if:{{{ml|}}}|margin-left:{{{ml}}}em;}}<!--
+
-->|left=float:left; {{#if:{{{mr|}}}| margin-right:{{{mr}}}em;| margin-right=0.5em;}} {{#if:{{{ml|}}}|margin-left:{{{ml}}}em;}}<!--
−
-->|#default=float:right; {{#if:{{{ml|}}}|margin-left:{{{ml}}}em;|margin-left:0.5em;}} {{#if:{{{mr|}}}|margin-right:{{{mr}}}em;}}<!--
+
-->|#default=float:right; {{#if:{{{ml|}}}| margin-left:{{{ml}}}em;| margin-left:0.5em;}} {{#if:{{{mr|}}}| margin-right:{{{mr}}}em;}}<!--
 
-->}}<!--
 
-->}}<!--
−
-->{{#if:{{{pb|}}}|padding-bottom:{{{pb}}}px;}} {{#if:{{{border|}}}|border:thin solid {{{border}}};}}">[[File:{{{1}}}|{{{2}}}x{{{3}}}px]]</span><!--
+
-->{{#if:{{{border|}}}| border:thin solid {{{border}}};}}<!--
 +
-->{{#if:{{{pad|}}}| padding:{{{pad}}}em;}}">[[File:{{{1}}}|{{{2}}}x{{{3}}}px]]</span><!--
 
-->}}<noinclude>{{doc2}}</noinclude>
 
-->}}<noinclude>{{doc2}}</noinclude>

Latest revision as of 00:17, 21 December 2019

[[File:{{{1}}}|{{{2}}}x{{{3}}}px]]

[edit] Documentation

Template which uses MediaWiki's "File:" syntax for images with captions and borders, as an alternative to the not-very-pretty ones that come built-in. Very similar to Template:img, but only uses uploaded files.
MediaWiki did something similar in 2014, but ditched it due to problems with videos. See Thumbnail style update.

Found a template, which looks very similar to MediaWiki's own version.

Usage

The first 3 parameters are mandatory; all others are optional.
{{FileCaption
|img-name  - filename of the image
|000       - width
|000       - height
|float=    - [none|left|right]. Default is float=right; margin-left=0.5em.
                                If float=right, then ml=0.5em.
|ml        - margin-left. No default.
|mr        - margin-right. No default.
|border    - border colour. See ColorBoxes below for some choices.
|caption   - caption
|pad       - padding between image and border; 0.2em is ok.
}}

 Dark: #808080   Medium: #a0a0a0   Light: #bebebe 

Example

{{FileCaption|Nuclear-Waste-Low-Level-Site.png|200|137|float=right|border=#a0a0a0|caption=[http://news.bbc.co.uk/ BBC Guide] to UK Nuclear Power{{plink|http://news.bbc.co.uk/}}

Gives:

Nuclear-Waste-Low-Level-Site.pngBBC Guide to UK Nuclear Power