Template:Plain image with caption View history

(Imported template from Wikipedia)
 
No edit summary
 
Line 1: Line 1:
<div class="{{#ifeq: {{{4|{{{align|right}}}}}} | right | floatright | {{#ifeq: {{{4|{{{align|left}}}}}} | left | floatleft | center}} }}">
{| style="float:{{{4|{{{align|right}}}}}}; width:{{{3|{{{width|250}}}}}}px; margin:1em; background:transparent;"
<div class="thumbinner" style="background:none;border:none;max-width:{{Str number/trim|{{{3|{{{width|250px}}}}}}}}px;">
|[[Image:{{{1|{{{image<noinclude>|Example.svg</noinclude>}}}}}}|right|{{{3|{{{width|250}}}}}}px|{{{2|{{{caption<noinclude>|Caption goes here.</noinclude>}}}}}}]]
{{#ifeq: {{{5|{{{caption position|bottom}}}}}} | top | {{#if: {{{9|{{{caption override|}}}}}} | <div class="thumbcaption">{{{9|{{{caption override|}}}}}}</div> | <div class="thumbcaption">{{#ifeq: {{{6|{{{triangle|none}}}}}} | triangle | <div style="float: left; margin-top: 0.25em; width: 11px; height: 9.5px;"><div style="position: relative; float: left; width: 0px; height: 0px; -webkit-transform: rotate(360deg); border-style: solid inset; border-width: 9.5px 5.5px 0 5.5px; border-color: {{{7|{{{triangle color|#ff0080}}}}}} transparent transparent transparent;"></div></div> | }}<div style="{{#ifeq: {{{6|{{{triangle|none}}}}}} | triangle | padding-left: 24px;}}">{{{2|{{{caption<noinclude>|Caption goes here.</noinclude>}}}}}}</div> }} </div>}}<!--
|-
-->{{#if: {{{8|{{{image override|}}}}}} | {{{8|{{{image override|}}}}}} | [[File:{{Remove file prefix|{{{1|{{{image<noinclude>|Example.svg</noinclude>}}}}}}}}|none|{{Str number/trim|{{{3|{{{width|250px}}}}}}}}px|{{{2|{{{caption<noinclude>|Caption goes here.</noinclude>}}}}}}]] }}<!--
|<span style="font-size:85%;">{{{2|{{{caption<noinclude>|Caption goes here.</noinclude>}}}}}}</span>
-->{{#ifeq: {{{5|{{{caption position|bottom}}}}}} | bottom | {{#if: {{{9|{{{caption override|}}}}}} | <div class="thumbcaption">{{{9|{{{caption override|}}}}}}</div> | <div class="thumbcaption">{{#ifeq: {{{6|{{{triangle|none}}}}}} | triangle | <div style="float: left; margin-top: 0.25em; width: 11px; height: 9.5px;"><div style="position: relative; width: 0px; height: 0px; border-style: solid inset; border-width: 0 5.5px 9.5px 5.5px; border-color: transparent transparent {{{7|{{{triangle color|#ff0080}}}}}} transparent;"></div></div> | }}<div style="{{#ifeq: {{{6|{{{triangle|none}}}}}} | triangle | padding-left:24px;}} ">{{{2|{{{caption<noinclude>|Caption goes here.</noinclude>}}}}}}</div> }} </div> }}
|}<noinclude>{{documentation}}</noinclude>
</div>
</div><noinclude>{{doc}}</noinclude>

Latest revision as of 13:18, 10 February 2016

Caption goes here.
Caption goes here.
Caption goes here.
Documentation icon Template documentation[view] [edit] [history] [purge]

Since MediaWiki does not provide a way to add visible captions to images integrated seamlessly in a page (i.e, without borders), this template aims to provide that functionality.

Usage

This template can be either with named parameters, as in

{{plain image with caption|image=Example.svg|caption=Example text|width=250|align=right}}

...or in its shorthand form:

{{plain image with caption|Example.svg|Example text|250|right}}
  • The only compulsory parameters are image and caption. The width defaults to 250px, and the alignment defaults to right
  • When using the shorthand version, keep in mind that the order of parameters is important
  • Please notice that the width does not include the unit "px" (see the code below)

Technical

The template wraps the image in an HTML table wrapper bounding the wrapper margins relative to the image width. The table positions the construct right or left and isolates it from other page text intrusion with fixed padding.

Actual internal coding

The equivalance between placeholder and named parameters is shown here below:

{| style="float:{{{4|{{{align|right}}}}}}; width:{{{3|{{{width|250}}}}}}px;
 margin:1em; background:transparent;"
| [[Image:{{{1|{{{image<noinclude>|Example.svg</noinclude>}}}}}}
| right|{{{3|{{{width|250}}}}}}px|{{{2|{{{caption<noinclude>|Caption goes here.</noinclude>}}}}}}]]
|-
|<span style="font-size:85%;">{{{2|{{{caption<noinclude>|Caption goes here.</noinclude>}}}}}}</span>
|}

So the placeholder parameters map as named parameters to operational HTML in order:

  1. image:   {{{image}}} or {{{1|}}}
  2. caption: {{{caption}}} or {{{2|}}}
  3. width:  {{{width}}} or {{{3|}}}defaults to 250 and adds the 'px;' suffix, so leave it off!
  4. float:   {{{align}}} or {{{4|}}}
The above documentation is transcluded from Template:Plain image with caption/doc.
Please add categories to the /doc subpage.
Subpages of this template.