Difference between revisions of "Template:Multiple image"

From Kerbal Space Program Wiki
Jump to: navigation, search
(Add the ability for multiple pictures)
 
m
Line 1: Line 1:
{{#if:{{{image1|}}}{{{image2|}}}{{{image3|}}}{{{image4|}}}{{{image5|}}}{{{image6|}}}{{{image7|}}}{{{image8|}}}{{{image9|}}}{{{image10|}}}|<div class="thumb {{#switch: {{{align|}}} | left = tleft|none | center|centre = tnone | right|#default = tright}}" style="max-width: {{#switch:{{{direction|}}}<!--
+
{{#if:{{{image1|}}}{{{image2|}}}{{{image3|}}}{{{image4|}}}{{{image5|}}}{{{image6|}}}{{{image7|}}}{{{image8|}}}{{{image9|}}}{{{image10|}}}|<div class="thumb {{#switch: {{{align|}}} | left = tleft|none | center|centre = tnone | right|#default = tright}}" style="width: {{#switch:{{{direction|}}}<!--
 
If stacked vertically, box width = largest width + 12 px (6 px margin on left and right) -->
 
If stacked vertically, box width = largest width + 12 px (6 px margin on left and right) -->
 
| vertical              = {{#expr:
 
| vertical              = {{#expr:

Revision as of 22:47, 14 April 2018

Documentation icon Template documentation[view] [edit] [history] [purge]Pages that link to Template:Multiple image

This template creates a box containing between two and ten images, arranged either vertically or horizontally and with captions for the entire box or per image.

With the appropriate choice of parameters, the template can automatically resize images to a given total width with each image having the same height.

Be aware that this template does not respect users' default image size preferences. (w:Wikipedia:Image use policy states: "Except with very good reason, do not use px"... "which forces a fixed image width. In most cases Template:Nobr should be used, thereby respecting the user's base preference (which may have been selected for that user's particular devices).")

If image size parameters are omitted, this template sets all images at 200px wide, regardless of whether the reader has set a preference for some other default image width. This causes multiple images to look out of scale to the other images in an article.

Syntax and parameters

Provide height[n] and total_width parameters to obtain automatic resizing. Note the different meanings of the width[n] parameters with vs. without automatic resizing.

No automatic resizing of all images to the same height
{{multiple image
<!-- Layout parameters -->
 | align             = <!-- right (default), left, center, none --> 
 | direction         = <!-- horizontal (default), vertical -->
 | background color  = <!-- box background -->
 | width             = <!-- displayed width of each image in pixels (an integer, omit "px" suffix); overrides "width[n]"s below -->
 | caption_align     = <!-- left (default), center, right --> 
<!-- Header -->
 | header_background = 
 | header_align      = <!-- center (default), left, right -->
 | header            = 
<!--image 1-->
 | image1            = <!-- filename only, i.e. without "File:" or "Image:" prefix -->
 | width1            = <!-- displayed width of image; overridden by "width" above -->
 | alt1              = 
 | link1             = 
 | thumbtime1        =
 | caption1          = 
<!--image 2-->
 | image2            = <!-- filename only, i.e. without "File:" or "Image:" prefix -->
 | width2            = <!-- displayed width of image; overridden by "width" above -->
 | alt2              = 
 | link2             = 
 | thumbtime2        =
 | caption2          = 
<!-- and so on, to a maximum of 10 images (image10) -->
<!-- Footer -->
 | footer_background = 
 | footer_align      = <!-- left (default), center, right -->
 | footer            = 
}}
Automatic resizing of all images to the same height and to a given total width
{{multiple image
<!-- Layout parameters -->
 | align             = <!-- right (default), left, center, none --> 
 | direction         = <!-- horizontal (default), vertical -->
 | background color  = <!-- box background -->
 | total_width       = <!-- total width of all the displayed images in pixels (an integer, omit "px" suffix) -->
 | caption_align     = <!-- left (default), center, right --> 
<!-- Header -->
 | header_background = 
 | header_align      = <!-- center (default), left, right -->
 | header            = 
<!--image 1-->
 | image1            = <!-- filename only, i.e. without "File:" or "Image:" prefix -->
 | alt1              = 
 | link1             = 
 | thumbtime1        =
 | caption1          = 
<!--image 2-->
 | image2            = <!-- filename only, i.e. without "File:" or "Image:" prefix -->
 | alt2              = 
 | link2             = 
 | thumbtime2        =
 | caption2          = 
<!-- and so on, to a maximum of 10 images (image10) -->
<!-- Footer -->
 | footer_background = 
 | footer_align      = <!-- left (default), center, right -->
 | footer            = 
}}
Parameter Description
align right (default), left, center
direction horizontal (default), vertical
background color To set the background color of the box in which the images appear.
header_background
header_align center (default), left, right
header
width Use to set the same width for each image (i.e. overrides any width[n] below). Do not include if different image widths intended, including if images are to be resized to a fixed total width.
total_width Use to scale the images to the same height and this total width. Do not use both total_width and width.
image[n] (where [n] = 1 to 10)  Filename of [n]th image.
width[n] (as above)  Two meanings: (1) The width (in pixels, integer, omit "px") of [n]th image. Overridden by width (if set). (2) The full width of the original [n]th image if total_width is given in order to resize all images to the same height and a given total width.
height[n] (as above)  The full height of the original [n]th image if total_width is given in order to resize all images to the same height and a given total width. Ignored otherwise.
alt[n] (as above)  Alt description for [n]th image.
link[n] (as above)  To specify the page to which the [n]th image is linked (i.e. the page that is loaded when the image is clicked). If set as empty (e.g. ...|alt1=... |link1= |caption1=...), linking is disabled (even to the standard Wikipedia image description page); consider w:WP:ALT.
Note: This parameter must not be used with images that have been given w:free licenses (such as the GDFL or a free CC license) as these licenses require images to be linked to a declaration of the license under which they are being used.
thumbtime[n] (as above)  When using Ogg Theora files, sets the time within the video that is used for the initial display. This is either a number of seconds or hours:minutes:seconds; see commons:Commons:Video#Setting a video thumbnail image.
caption[n] (as above)  Caption for the [n]th image.
caption_align left (default), center, right
footer_background
footer_align left (default), center, right
footer Caption that spans the entire box, as opposed to individual images. Avoid "left" and "right" if possible, since mobile devices may display the images vertically.

Examples

Yellow cartouche
Red cartouche
Players are cautioned with a yellow card and sent off with a red card.
{{multiple image
 | width = 60
 | image1 = Yellow card.png
 | alt1 = Yellow cartouche
 | image2 = Red card.png
 | alt2 = Red cartouche
 | footer = Players are cautioned with a yellow card and sent off with a red card.
}}

More examples

For more examples see the Wikipedia page.