Template:Modern gallery
Purpose
This template builds a styled, modern gallery from a hand-picked list of files. Each tile can have a caption, and both the tile and the caption link to the same place. Use it for curated sets like featured resources, where the items don't come from a Cargo query.
Usage
Use it anywhere you would otherwise write a raw <gallery> with <center>[url caption]</center> lines. Uploaded PDFs show their first page as the thumbnail.
Syntax
The shortest form lists the files on their own. Each one links to the uploaded file, and its caption is the file name:
{{Modern gallery
|Pest grasshoppers in Oregon.pdf
|Common Wyoming Pest Grasshoppers.pdf
}}
Add numbered parameters only for the items that need them:
{{Modern gallery
|Pest grasshoppers in Oregon.pdf
|Species fact sheet Pallidwinged Grasshopper.pdf
|label2=ARS species fact sheet: Pallid-winged grasshopper
|url2=https://www.ars.usda.gov/...pdf
}}
Parameters
imageN— the file name, with or without theFile:prefix. You can also leave the name off and list the files on their own, as in the examples above. Numbering must start at 1 and not skip numbers.labelN— caption text. Defaults to the file name without its extension.urlN— where the tile and the caption go. Anhttp(s)address becomes an external link, and anything else is treated as a wiki page name. For example,File:Name.pdfgoes to the file's description page. If you leave it out, the link opens the uploaded file itself (for example, the PDF).linkN— optional. Sends the image somewhere different from the caption.sourceN— optional. The publisher or organization, shown as a small green label above the title (for exampleUSDA ARS). Documents only.widths— tile width. Defaults to175px.heights,perrow— standard gallery options.show_captions—always(default) orhover.variant— chosen automatically. When every image is a PDF you getdocuments: each whole page shown without cropping, on a light background. Otherwise you getportraits: every photo cropped to the same 3:4 shape, anchored at the top so faces line up. Setvariant=documentsorvariant=portraitsto choose one yourself, ornoneto show each photo at its own shape.
meta— set tonoto hide the line that is added automatically under each document title (for example PDF · 48 pages · 3.2 MB). The line comes from the uploaded file, so editors don't need to type it.
Documents look: each card stretches to fill the row, and the whole card is clickable. The page is shown uncropped on a grey background. Titles stop at three lines, and the full title shows when you hover over the link.
Handling errors
If no image1 is given, the template shows an error message where the gallery would be.
Developer notes
The template calls Module:Gallery's manual_gallery function. That function builds the items and renders them through build_modern_gallery, which is the same wrapper and .modern-gallery CSS that Template:Person gallery modern uses.