Template:Plain image with caption/doc View history

(template currently broken)
No edit summary
 
Line 1: Line 1:
{{Documentation subpage}}
{{doc subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
<!-- ADD DOCUMENTATION BELOW THIS LINE -->
 
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.
NOTE: This template is currently not operational with the current version of the Waze Wiki. It requires templates that use #invoke and LUA scripts.
 
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 ===
=== Usage ===
This template can be either with named parameters, as in
This template can be either with named parameters, as in
: <tt><nowiki>{{Plain image with caption|image=Example.svg|caption=Example text|width=250px|align=right|caption position=bottom}}</nowiki></tt>
:<tt><nowiki>{{plain image with caption|image=Example.svg|caption=Example text|width=250|align=right}}</nowiki></tt>
...or in its shorthand form:
...or in its shorthand form:
: <tt><nowiki>{{Plain image with caption|Example.svg|Example text|250px|right|bottom}}</nowiki></tt>
:<tt><nowiki>{{plain image with caption|Example.svg|Example text|250|right}}</nowiki></tt>
* The only compulsory parameters are <tt>image</tt> and <tt>caption</tt>.
* The only compulsory parameters are <tt>image</tt> and <tt>caption</tt>. 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
* 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:
<pre>
{| 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>
|}</pre>


{| cellspacing="2" cellpadding="4"
So the placeholder parameters map as named parameters to operational HTML in order:
|- bgcolor="#ddd" bordercolor: #fff
# <tt>image: &nbsp; <nowiki>{{{image}}} or {{{1|}}}</nowiki></tt>
| '''Parameter'''
# <tt>caption:&nbsp;<nowiki>{{{caption}}} or {{{2|}}}</nowiki></tt>
| '''Default'''
# <tt>width:  &nbsp;<nowiki>{{{width}}} or {{{3|}}}</nowiki></tt>&mdash; '''defaults to 250 and ''adds the 'px;'''''' ''suffix'', so leave it off!
| '''Acceptable values'''
# <tt>float: &nbsp; <nowiki>{{{align}}} or {{{4|}}}</nowiki></tt>
 
|- bgcolor="#eee"
| image
| ''mandatory''
| any image filename (''"File:"'' or ''"Image:"'' is optional)
 
|- bgcolor="#eee"
| caption
| ''mandatory''
| any valid wiki markup
 
|- bgcolor="#eee"
| width
| 250px
| any pixel width (''"px"'' suffix optional)
 
|- bgcolor="#eee"
| align
| right
| left, center, right
 
|- bgcolor="#eee"
| caption position
| bottom
| top, bottom
 
|- bgcolor="#eee"
| triangle
| none
| triangle, none
 
|- bgcolor="#eee"
| triangle color
| #ff0080
| any css color
 
|- bgcolor="#eee"
| image override
|
| Anything (lets you replace the image block with anything—useful for stacking image overlays)
 
|- bgcolor="#eee"
| caption override
|
| Anything (lets you replace the caption block with anything)
|}
 
== Examples ==
 
The triangle parameters give the option to add a colored triangle label—
{{plain image with caption|James Webb Space Telescope Mirror37.jpg|This is a picture of the [[James Webb Space Telescope]]. Note the small triangle next to this caption.|350|left|top|triangle|rgba(0,110,255,1)}}
<tt><nowiki>{{plain image with caption|James Webb Space Telescope Mirror37.jpg|This is a picture of the [[James Webb Space Telescope]].|350|left|top|triangle|rgba(0,110,255,1)}}</nowiki></tt>
 
{{clear}}
 
Using "image-override" to stack images
 
{{Plain image|File:Helical granum.png|'''Grana structure''' The prevailing model for [[granum|granal]] structure is a stack of granal [[thylakoids]] linked by helical [[stroma (fluid)|stromal]] thylakoids that wrap around the grana stacks and form large sheets that connect different grana.|432px|left|top|triangle|#3cb14d|image override=<div style="float: right; position: relative; width: 432px; height: 432px;">
<div style="float: right; position: absolute; width: 432px;">[[File:Helical granum.png|432px]]</div>
<div style="float: right; position: absolute; width: 432px;">[[File:Granum labels.svg|432px|The prevailing model for [[granum|granal]] structure.]]</div></div>}}
<tt><nowiki>{{Plain image|File:Helical granum.png|'''Grana structure''' The prevailing model for [[granum|granal]] structure is a stack of granal [[thylakoids]] linked by helical [[stroma (fluid)|stromal]] thylakoids that wrap around the grana stacks and form large sheets that connect different grana.|432px|left|top|triangle|#3cb14d|image override=<div style="float: right; position: relative; width: 432px; height: 432px;">
<div style="float: right; position: absolute; width: 432px;">[[File:Helical granum.png|432px]]</div>
<div style="float: right; position: absolute; width: 432px;">[[File:Granum labels.svg|432px|The prevailing model for [[granum|granal]] structure.]]</div></div>}}</nowiki></tt>
 
{{clear}}
 
== TemplateData ==
{{TemplateData header}}
<templatedata>
{
        "description": "A template for adding a caption to a frameless image",
        "params": {
                "image": {
                        "label": "Image",
                        "description": "The image to use. The ''File:'' prefix is optional.",
                        "type": "string",
                        "default": "—",
                        "required": true
},
                "caption": {
                        "label": "Image caption and alt text",
                        "description": "The caption to display under or above the image. Also sets the alt text.",
                        "type": "string",
                        "default": "—",
                        "required": true
                    },
                "width": {
                        "label": "Image width",
                        "description": "Sets the pixel width of the image and the template. the ''px'' suffix is optional.",
                        "type": "number",
                        "default": "250px",
                        "required": false
                    },
                "align": {
                        "label": "Float and center",
                        "description": "Floats the template to the left, right, or centers it. Accepts ''left'', ''center'', or ''right''.",
                        "type": "string",
                        "default": "right",
                        "required": false
                    },
                "caption position": {
                        "label": "Caption position",
                        "description": "Determines whether the caption goes above or below the image. Accepts ''top'' or ''bottom''.",
                        "type": "string",
                        "default": "bottom",
                        "required": false
                    },
                "triangle": {
                        "label": "Triangle pointer",
                        "description": "Allows you to add a triangular pointer next to the caption text. Accepts ''triangle'' or ''none''.",
                        "type": "string",
                        "default": "none",
                        "required": false
                    },
                "triangle color": {
                        "label": "Triangle pointer color",
                        "description": "Lets you set a CSS color for the triangular pointer.",
                        "type": "string",
                        "default": "#ff0080",
                        "required": false
                    },
                "image override": {
                        "label": "Replacement content for the image",
                        "description": "Lets you substitute any allowed HTML where the image would normally be.",
                        "type": "string",
                        "default": "—",
                        "required": false
                    },
                "caption override": {
                        "label": "Replacement content for the caption",
                        "description": "Lets you substitute any allowed HTML where the caption would normally be.",
                        "type": "string",
                        "default": "—",
                        "required": false
                    }
                }
}
</templatedata>
 
=== See also ===
* {{tl|Multiple image}}
* {{tl|Double image}}
* {{tl|Triple image}}


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<includeonly>
<!-- Categories below this line, please; interwikis at Wikidata -->
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:Graphics templates]]
[[Category:Graphic templates|{{PAGENAME}}]]
}}</includeonly>
[[category:Typing-aid templates|{{PAGENAME}}]]
</includeonly>

Latest revision as of 13:22, 10 February 2016

This is a documentation subpage for Template:Plain image with caption.
It contains usage information, categories and other content that is not part of the original template page.

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|}}}