Jump to content

Template:Gallery

From Wikinews, the free news source you can write!
{{{2}}}
{{{2}}}  
[edit] Template documentation

Usage

[edit]

The {{Gallery}} template displays a flexible, auto-wrapped table of images with optional captions, widths, and heights. It supports up to 110 images, each using paired parameters for the file name and its caption.

Each image is rendered via the helper template {{Gallery/aux}}.

Basic syntax

[edit]
{{Gallery
|title=Gallery Title (optional)
|1=File:Example1.jpg |2=Caption for image 1
|3=File:Example2.jpg |4=Caption for image 2
|5=File:Example3.jpg |6=Caption for image 3
...
|footer=Optional footer text
}}

Example

[edit]
{{Gallery
|title=Sample image gallery
|1=File:Sunset.jpg |2=Sunset over mountains
|3=File:Ocean.jpg  |4=Waves crashing on shore
|5=File:Forest.jpg |6=Misty woodland
|footer=All photos are licensed CC-BY-SA.
}}

Parameters

[edit]

Global settings

[edit]
  • style= – CSS styling for the outer table. Default: background:transparent; border:1px solid #f0f0f0;
  • align= – Optional alignment of the gallery (e.g., center, left, right).
  • title= – Optional title displayed above the image grid.
  • footer= – Optional footer displayed below the gallery.
  • width= – Default width (px) for all images. Default: 180.
  • height= – Default height (px) for all images. Default: 180.
  • cellwidth= – Width of each cell. Default: 180.
  • lines= – Number of lines allowed for captions. Default: 2.
  • boxform= – Optional formatting style for image boxes.

Image-specific parameters

[edit]

Each image is defined in pairs:

  • 1=, 3=, ..., 219= – File names (e.g., File:Example.jpg)
  • 2=, 4=, ..., 220= – Captions
  • alt1=, alt2=, ..., alt110= – Optional alt text for each image
  • width1=, width2=, ..., width110= – Optional custom width per image

Notes

[edit]
  • Supports up to 110 images.
  • Images are auto-wrapped based on available horizontal space.
  • Captions automatically break into multiple lines, controlled by the lines= parameter.
  • Custom alt text and per-image widths allow for fine-tuning accessibility and layout.

See also

[edit]
  • {{Gallery/aux}} – helper used by this template
  • {{Gallery}}/sandbox – for testing edits

Template data

[edit]

Displays up to 110 images in an auto-wrapping table, each with a caption and customizable dimensions.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Titletitle

Optional title displayed above the gallery

Stringoptional
Footerfooter

Optional footer displayed below the gallery

Stringoptional
Stylestyle

Custom CSS style for the outer table

Stringoptional
Alignalign

Alignment of the gallery (left, center, right)

Stringoptional
Default widthwidth

Default width for images

Default
180
Numberoptional
Default heightheight

Default height for images

Default
180
Numberoptional
Cell widthcellwidth

Width of each image cell

Default
180
Numberoptional
Caption lineslines

Max number of caption lines

Default
2
Numberoptional
Box formboxform

Optional formatting override for image boxes

Stringoptional