Template:G

Template documentation[view · edit · history · purge]
This documentation is transcluded from Template:G/doc.
The creator of the template User Sarang passed away on September 20, 2023, four months after working on this documentation.
Condolences

Displays a gallery of files, using just the conventional <gallery> tag, but with shorter parametrizing and some useful defaults.

Usage


{{G |1= }}

Such a gallery can contain one file or more, up to an unlimited number:

  • with just {{ G | filename }} a 'gallery' of a single file can be shown,
  • with e.g. {{ G | filename1 | filename2 |  }} more files are displayed.

The display format can be influenced by several additional options.

The parameter "w", "d", "h"

The display size can be specified with either widths and/or heights, or with display.
While "w" and "h" can specify the number of the pixels, "d" consists of three optional parts: [w] [xh] [px].
"w" and/or "h" have precedence: "d" is only checked when neither "w" nor "h" are specified.

The parameter "format"

can specify with one of the following numbers how naming captions for the single files are displayed:

  1. no naming; same as specifying an empty f= , or another value
  2. naming with the "showfilename" option
  3. naming with the second value of parameter pairs (default is the first value, linked)
  4. same as format=2 but the defaults are displayed without link
  5. same as format=2 (default is the first value, linked, but without the extension)
  6. same as format=4 but the name is not linked
Category:Main message boxes
Defaulting the "format"

The parameter format is a necessary addition to the parameters used by <gallery>.
When the most frequent invocation form for <gallery> is used, i.e.

  • the first parameter is preceded by a linefeed,
  • and the second parameter exists,
  • and it is separated from the first one by a pipe,
  • and it does not also end with a . and file extension

then no format must be specified, "f=2" is assumed, and
the display with {{G|}} is the almost same as with <gallery></gallery>.
When not all these requirements are fulfilled, the parameter needs to be specified!
Otherwise a missing format parameter is defaulted with "f=1".

Category:Main message boxes

File list notations

The list of the files ("items") for the gallery can be specified in the notation

List 1
{{ G | file1.ext | file2.ext |  | filen.ext | more parameters }}

or as a list separated by mandatory linefeeds

List 2
{{ G | 
file1.ext
file2.ext

filen.ext
| more parameters }}

Also a mixture of both notations is possible.

Category:Main message boxes

For format=2 parameter pairs of file + description must be specified:

List 3
{{ G | file1.ext | description1 | file2.ext | description2 |  | filen.ext | descriptionn |  f = 2 | more parameters }}

This format needs always parameter pairs, but the description may be without value (just a pipe or an empty new line).
When the description is empty, the name of the file is displayed instead; but a description as e.g. &nbsp; will be used!

Category:Main message boxes

A good idea for an easy way to read input will be (with the possibility not to need the 'format' parameter)

{{ G | 
file1.ext
| name1
file2.ext
| name2

| more parameters }}

Indentions

Indentions are not intended by the <gallery> tag, if any are required the align attribute of tables can be used, e.g.
{|
|style="padding-left:2em"|{{G|}}
|}

Template parameters

ParameterDescriptionDefaultStatus
1(list of) file(s) to be displayed, can be in different ⇒ notationsemptysuggested
f
format
one of the six numbers to specify the ⇒ format: 0 to 5
whether or how the displayed image(s) should be captioned
1 or 2optional
m
mode
gallery mode, can be specified with
t or traditional
n or nolines,
p or packed,
h or packed-hover,
o or packed-overlay,
s or slideshow
when parameter format is not specified, nolines is defaulted, but that defaulting can be avoided with an empty mode parameter m=
emptyoptional
c
caption
gallery caption (may be shifted to the left with e.g. some trailing &emsp; entities)emptyoptional
p
perrow
pictures per rowemptyoptional
s
style
style attributes, e.g. s=float:rightemptyoptional
a
attr, class
class attributes: any wikimedia class;
or the special code "c" (a=c) for a global <center> tag
emptyoptional
w
widths
width for the displaysemptyoptional
h
heights
height for the displaysemptyoptional
d
display
display size; can specify widths and heightsemptyoptional
n
notself
when invoked from a file: don't display the image itselfemptyoptional
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. <nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw <templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.


Wikipedia's help about TemplateDataCommons-specific information

Category:Templates using TemplateData

Displays a gallery of files, using just the conventional "gallery" tag, but with shorter parametrizing and some useful defaults.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
1

(list of) file(s) to be displayed, can be in different ⇒ notations

Unknownsuggested
a attr, class

class attributes: any wikimedia class; or the special code "c" ("a=c") for a global <center> tag

Unknownoptional
c caption

gallery caption (may be shifted to the left with e.g. some trailing &emsp; entities

Unknownoptional
d display

display size; can specify "widths" and "heights"

Unknownoptional
f format

one of the six numbers to specify the ⇒ format: 0 to 5, whether or how the displayed image(s) should be captioned

Default
1 or 2
Unknownoptional
h heights

height for the displays

Unknownoptional
m mode

gallery mode, can be specified with t or traditional, "n" or "nolines", "p" or "packed", "h" or "packed-hover", "o" or "packed-overlay", "s" or "slideshow", when parameter "format" is not specified, "nolines" is defaulted, but that defaulting can be avoided with an empty mode parameter "m="

Unknownoptional
n notself

when invoked from a file: don't display the image itself

Unknownoptional
p perrow

pictures per row

Unknownoptional
s style

style attributes, e.g. "s=float:right"

Unknownoptional
w widths

width for the displays

Unknownoptional

Additional information

The template is intended to be used in the following namespaces: all namespaces

The template is intended to be used by the following user groups: all users

Relies on:

Category:Main message boxesCategory:Lua-based templates

See also

Localization

This template is not intended to be localized.

Category:Templates not requiring internationalization

Examples

See here for different parameterisations and item notations, separated with pipes (|) and linefeeds (¶).

Just one file without option parameters
{{G|
Example.png
}}
That image can as well be obtained with
<gallery mode="nolines" showfilename="yes">Example.png</gallery>
Some files, without option parameters
{{G|Example ba.svg|Example de.svg|Example bn.svg|Example de.svg|Example en.svg|Example ru.svg|Example lt.svg|Example ro.svg|Example tr.svg}}
{{G|Day-template.svg
Emojione 1F642.svg
Emojione BW 1F642.svg
Laughing-smiley.svg
Noto Emoji Oreo 1f642.svg
Noto Emoji Pie 1f642.svg
Line-style-icons-happy.svg
Nuvola emoticon - happy.svg
|f=0|w=48|m=n|c=eight smileys &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp;}}
globally centered with a=c
{{G|Blue king.svg|Chess kgt45.svg
|Chess krt45.svg|Chess kyt45.svg
|Green king.svg|Red king.svg
|Yellow king.svg|Chess kdt45.svg
|f=0|w=80|p=4|a=c}}
Some descriptions are missing. The input is easy to read this way and does not need the 'format' parameter. Namespace ("file" or "image") won't disturb.
{{G|
File:Pink check.svg|pink
Purple check.svg|purple
Olive green check.svg|{{W|olive}}
image:Yellow check.svg|yellow
Cornflower blue check.svg|blue
Black check.svg|
White check.svg|white
Green check.svg|green
File:Red_check.svg|
Orange check.svg|{{W|orange}}
Light green check.svg|green
|w=96}}
Not so easy to read that way:
{{G|EU-section-with-A.svg|{{W|Austria}}|EU-section-with-BG.svg|{{W|Bulgaria}}|EU-section-with-CY.svg|{{W|Cyprus}}
|EU-section-with-CZ.svg|{{W|Czech}}|EU-section-with-D.svg|{{W|Germany}}|EU-section-with-DK.svg|{{W|Denmark}}
|EU-section-with-B.svg|{{W|Belgium}}|EU-section-with-EST.svg|{{W|Estonia}}|EU-section-with-FIN.svg|{{W|Finland}}
|EU-section-with-GR.svg|{{W|Greece}}|EU-section-with-IRL.svg|{{W|Irland}}|EU-section-with-SLO.svg|{{W|Slovenia}}|f=2|h=80|m=n}}
The description can also contain an URL.
{{G|
Structural-Iceberg-ca.svg|{{Plainlinks|http://lightningvolt.com/Image%20Gallery/imagegallery.htm|URL 1}}
Structural-Iceberg-cs.svg|{{W|{{#language:cs}}}}
Structural-Iceberg.svg|{{Plainlinks|1=https://npgallery.nps.gov/AssetDetail/NRIS/1111|2=NRHP}}
Structural-Iceberg-ja.svg|{{#language:ja}}
|w=48|m=n}}
Category:Marker templates#G Category:File namespace templates#G Category:One-letter templates#%20 Category:Gallery templates
Category:File namespace templates Category:Gallery templates Category:Lua-based templates Category:Main message boxes Category:Marker templates Category:One-letter templates Category:Templates not requiring internationalization Category:Templates using TemplateData