Template:Multiple image/doc: Difference between revisions

From IxWiki
Jump to navigation Jump to search
wp>WOSlinker
m change source to syntaxhighlight
 
m 1 revision imported
 
(No difference)

Latest revision as of 21:02, 16 August 2020

Lua error: bad argument #1 to "get" (not a valid title).

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. (Wikipedia:Image use policy states: "Except with very good reason, do not use px"... "which forces a fixed image width." MOS:IMGSIZE states that a fixed width in pixels may only be specified, "Where absolutely necessary.")[lower-alpha 1]

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. Please also note the option to set a total_width parameter at the beginning of the multiple image template.

No automatic resizing of all images to the same height
{{Multiple image|perrow = 1|total_width = 600
<!-- Layout parameters -->
| align             = <!-- right (default), left, center, none --> 
| direction         = <!-- horizontal (default), vertical -->
| background color  = <!-- box background as a 'hex triplet' web color (include the initial #) -->
| width             = <!-- displayed width of each image in pixels (an integer, omit "px" suffix); overrides "width[n]"s below -->
| caption_align     = <!-- left (default), center, right --> 
| image_style       = <!-- border:1; (default) -->
| image_gap         = <!-- 5 (default)-->

<!-- Header -->
| header_background = <!-- header background as a 'hex triplet' web color (include the initial #) -->
| header_align      = <!-- center (default), left, right -->
| header            = <!-- header text -->

<!--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 background as a 'hex triplet' web color (include the initial #) -->
| footer_align      = <!-- left (default), center, right -->
| footer            = <!-- footer text -->
}}
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)  The page linked to the [n]th image (i.e. the page that is loaded when the image is clicked).
  • If this parameter is omitted altogether, the image will link to its image description page as usual (this is by far the most common usage case).
  • If this parameter is present but left empty (i.e. ...|link1= |...), the image will not link to anything – this should be the case only for purely decorative images per WP:ALT.
  • Important: If the image is under a free license (such as the GDFL or a free CC license), the terms of such license require the license, or a link to it, to be reproduced with the image. The image must, therefore, link to its image description page, which can be achieved simply by omitting the link[n] parameter from the template as mentioned. Public domain and (theoretically) fair use images are not subject to this restriction.
thumbtime[n] (as above)  When using video 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.svg
 | alt1 = Yellow cartouche
 | image2 = Red card.svg
 | alt2 = Red cartouche
 | footer = Players are cautioned with a yellow card and sent off with a red card.
}}
PNG transparency demonstration
Colored dice with white background
A PNG image with an 8-bit transparency layer...
Colored dice with checkered background
...here overlaying a checkered background.
{{multiple image
 | align = left
 | direction = vertical
 | width = 200
 | header = [[Portable Network Graphics|PNG]] transparency demonstration
 | image1 = PNG transparency demonstration 1.png
 | alt1 = Colored dice with white background
 | caption1 = A PNG image with an 8-bit transparency layer...
 | image2 = PNG transparency demonstration 2.png
 | alt2 = Colored dice with checkered background
 | caption2 = ...here overlaying a checkered background.
}}
2
3
4
When a user has many of one type of barnstar, they can represent them with ribbons and these numerals to indicate the count.
{{multiple image
 | width = 60
 | image1=Ribbon numeral 2.png | alt1=2
 | image2=Ribbon numeral 3.png | alt2=3
 | image3=Ribbon numeral 4.png | alt3=4
 | footer = When a user has many of one type of [[WP:BARN|barnstar]], they can represent them with [[WP:RIBBON|ribbons]] and these numerals to indicate the count.
}}

With background color

Green herb with a few tiny yellow-white flowers
Three small white and yellow flowers before green-leaf background
Leaves of a plant, in groups of three each with three lobes
Adoxa (Adoxa moschatellina)
{{multiple image
 | background color = #BBDD99
 | width = 160
 | image1 = Adoxa_moschatellina_210406.jpg
 | alt1 = Green herb with a few tiny yellow-white flowers
 | image2 = Adoxa_moschatellina_210406a.jpg
 | alt2 = Three small white and yellow flowers before green-leaf background
 | image3 = adoxa_moschatellina_blatt.jpeg
 | alt3 = Leaves of a plant, in groups of three each with three lobes
 | footer_background = #BBDD99
 | footer_align = center
 | footer = [[Adoxa]] (''Adoxa moschatellina'')
}}

With links (link[n])

A mule
A mule
(骡子 luózi)
A donkey
A donkey
(驴子 lǘzi)
A trout
A fish
( )
The image of the mule links to Mule; the image of the donkey does not link anywhere; the image of the trout links to a standard image description page.
{{multiple image
 | align = left

 | image1 = Frecklesmule.jpg
 | width1 = 143
 | alt1 = A mule
 | link1 = Mule
 | caption1 = A mule<br />(骡子 ''luózi'')

 | image2 = Donkey 1 arp 750px.jpg
 | width2 = 150
 | alt2 = A donkey
 | link2 = 
 | caption2  = A donkey<br />(驴子 ''lǘzi'')

 | image3 = Rainbow_trout.png
 | width3 = 91
 | alt3 = A trout
 | caption3  = A fish<br />({{lang|zh|2=鱼}} '''')

 | footer = The image of the mule links to [[Mule]]; the image of the donkey does not link anywhere; the image of the trout links to a [[Image description page|standard image description page]].
}}

Using direction

By default, the images the template presents are displayed horizontally, as a row (see left; equivalent to setting |direction=horizontal). To display them vertically, i.e. as a column, set |direction=vertical (see right).

(horizontal)
(vertical)

On mobile devices some images may always be displayed vertically if the total width is larger than around 320.

To match image heights

Note: The following is unnecessary if all the images presented by the template have the same aspect ratio; if so, simply set width accordingly.
  • Decide on a total width for all the images, say 320px
  • Set the total width using |total_width=
A donkey
Rectangular image of a donkey, originally 536 pixels high.
A trout
Square image of a trout, originally 300 pixels high.
Both images have been rendered with the same height, and a total width of 320px
{{multiple image
 | align = right
 | total_width = 320

 | image1 = Donkey 1 arp 750px.jpg
 | alt1 = A donkey
 | caption1 = Rectangular image of a donkey, originally 536 pixels high.

 | image2 = Rainbow_trout.png
 | alt2 = A trout
 | caption2 = Square image of a trout, originally 300 pixels high.

 | footer = Both images have been rendered with the same height, and a total width of 320px
}}

The aspect ratio of each image is automatically retrieved from the File metadata. You can override the native width and height values by

  • Examining the individual image pages to obtain the full resolution. For example:
  • Specify the full width and height for each image, of the form:
    • |width1= |height1= |width2= |height2=

Multiple rows

To create an array of images, with multiple rows, use |perrow=. The value passed to |perrow= may be a single number, or a list of numbers delimited by /. This feature may also be combined with |total_width= for multiple rows of images with the same total width.

Surveying Equipment. Clockwise from upper left: Optical Theodolite, Robotic total station, Optical level, RTK GPS Base station.
{{multiple image|perrow = 2|total_width=300
| image1 = Kern_Theodolit_DKM2-A.jpg
| image2 = Total-Robotic-Station.jpg
| image3 = DumpyLevel.jpg
| image4 = GPS_Survey_Equipment_at_Weir_Dyke_Bridge_-_geograph.org.uk_-_336908.jpg
| footer = Surveying Equipment. Clockwise from upper left: Optical Theodolite, Robotic total station, Optical level, [[Real-time kinematic | RTK]] GPS Base station.
}}

Removing the image border

The border around the images can be removed using |image_style=border:none.

A donkey
Image of a donkey
A trout
Image of a trout
{{multiple image
 | align = right
 | total_width = 320
 | image_style = border:none;

 | image1 = Donkey 1 arp 750px.jpg
 | alt1 = A donkey
 | caption1 = Image of a donkey

 | image2 = Rainbow_trout.png
 | alt2 = A trout
 | caption2 = Image of a trout
}}

Increasing the gap between images

The gap between the images can be increased using |image_gap=N, where N is the number of pixels (must be non-negative).

A donkey
Image of a donkey
A trout
Image of a trout
{{multiple image
 | align = right
 | total_width = 320
 | image_gap = 20

 | image1 = Donkey 1 arp 750px.jpg
 | alt1 = A donkey
 | caption1 = Image of a donkey

 | image2 = Rainbow_trout.png
 | alt2 = A trout
 | caption2 = Image of a trout
}}

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Multiple image in articles based on its TemplateData.

TemplateData for Multiple image

This template creates a box with two to ten images arranged vertically or horizontally with captions for the entire box and each image.
ParameterDescriptionTypeStatus
Alignmentalign
Sets text-wrapping around image box, where "none" places the box on the left edge with no text-wrapping, "center" places the box at center with no text-wrapping and "left" and "right" refer to position of box on screen with text-wrapping.
Default
right
Example
left/right/center/none
Stringsuggested
Directiondirection
Direction in which to tile the images.
Default
horizontal
Example
horizontal/vertical
Stringsuggested
Frame widthtotal_width
Use to scale the images to the same height and this total width. Do not use both total_width and width. Integer width in pixels; no "px" suffix
Example
400
Numbersuggested
Row layoutperrow
Create an array of images, with multiple rows. The value passed to may be a single number or a list of numbers with each row delimited by /. Can be combined with total_width for automatic sizing of images.
Example
1 / 2 / 1
Stringoptional
Image widthwidth
Width overrides Width 1, Width 2, Width 3, etc. If you want the images to be different sizes, do not provide the width parameter. Integer width in pixels; no "px" suffix
Example
200
Numberoptional
Background colorbackground color
Defines the background color between the border of the box and the images. Changing the background can be bad for accessibility, avoid when possible.
Example
#EEFFGG or red
Stringoptional
Caption alignmentcaption_align
Default
left
Example
left/right/center
Stringoptional
Image 1image1
Image 1 is name of first image. Similarly for Image 2, etc. File name only; no "File:" or "Image:" prefix.
Example
example.jpg
Filerequired
Width 1width1
Width 1 is width of first image. Similarly for Width 2, etc.
Numberoptional
Alt text 1alt1
The alt text of first image (see WP:ALT). Similarly for Alt text 2, etc.
Linesuggested
Caption 1caption1
Caption 1 is caption of first image. Similarly for Caption 2, etc.
Contentsuggested
Link 1link1
Where the first page links to. Similarly for Link 2, etc. If not specified, image links to the image description page as usual. If specified to the empty value, the image does not link anywhere; this should be used for purely decorative images as per WP:ALT. Important: If the image is under a free license like the GFDL or a CC license, you must not use this parameter as the terms of those licenses require the license, or a link to it, to be reproduced with the image. The image must, therefore, link to its image page. Public domain and (theoretically) fair use images are not subject to this restriction.
Page nameoptional
Thumbtime 1thumbtime1
If image1 is an Ogg Theora file, sets the time within the video that is used for the initial display. Either a number of seconds or hours:minutes:seconds. Similarly for Thumb time 2, etc.
Stringoptional
Image 2image2
Example
example.jpg
Filesuggested
Width 2width2Numberoptional
Alt text 2alt2Lineoptional
Caption 2caption2Contentsuggested
Link 2link2Page nameoptional
Thumbtime 2thumbtime2Stringoptional
Image 3image3
Example
example.jpg
Fileoptional
Width 3width3Numberoptional
Alt text 3alt3Lineoptional
Caption 3caption3Contentoptional
Link 3link3Page nameoptional
Thumbtime 3thumbtime3Stringoptional
Image gapimage_gap
Override the distance between adjacent images. Integer width in pixels; no "px" suffix
Example
20
Numberoptional
Image styleimage_style
Override the default styling of the image frame.
Stringoptional
Headerheader
A header text to place above the entire frame.
Contentoptional
Header backgroundheader_background
Defines the background color of the header field. Changing the background can be bad for accessibility, avoid when possible
Example
#EEFFGG or red
Stringoptional
Header alignmentheader_align
Default
center
Example
left/right/center
Stringoptional
FooterfooterContentoptional
Footer backgroundfooter_background
Defines the background color of the footer field. Changing the background can be bad for accessibility, avoid when possible
Example
#EEFFGG or red
Stringoptional
Footer alignmentfooter_align
Default
left
Example
left/right/center
Stringoptional

Format: block

Tracking categories

Notes

  1. The |upright= parameter can only be used to relatively-size an image when using the |thumb= parameter, and this template needs to format images without thumbs, so it has no easy way to access the Wikimedia relative-sizing machinery.

See also