Template:Gallery/doc: Difference between revisions

Template page
(Created page with "{{Documentation}} ;Description :This template is used to implement gallery section into a page ;Syntax :Type <code><nowiki>{{Gallery|<<image 1>>|<<image 2>>|<<image 3>>|<...>|<<image 9>>}}</nowiki></code> ;Sample output :<code><nowiki>{{Gallery|tapir.jpg|tapirfront.jpg|tapirback.jpg}}</nowiki></code> ;References <references/>")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Documentation}}
This template provides advanced gallery building functionality (fine-tuned formatting control).
;Description
 
:This template is used to implement gallery section into a page
This template displays a gallery of images in an array, left-to-right in rows.  Global parameters {{para|width}} and {{para|height}} control the size of all images in the gallery. The number of images per row is based upon the image width parameters and the width of the screen. The number of images per row can change when the user resizes the window.
;Syntax
 
:Type <code><nowiki>{{Gallery|<<image 1>>|<<image 2>>|<<image 3>>|<...>|<<image 9>>}}</nowiki></code>
{| style="background: transparent;"
;Sample output
|<pre>{{Gallery
:<code><nowiki>{{Gallery|tapir.jpg|tapirfront.jpg|tapirback.jpg}}</nowiki></code>
| title        =
;References
| align        =
<references/>
| footer      =
| style        =
| class        =
| state        =
| height      =
| width        =
| captionstyle =
| File:
| alt1=
| Write a caption here
| File:
| alt2=
| Write a caption here
| File:
| alt3=
| Write a caption here
| File:
| alt4=
| Write a caption here
| File:
| alt5=
| Write a caption here
}}</pre>
|}
 
== Parameters ==
 
=== For each image ===
 
Specify a line of the following form for each image.
: <code>|File:''Filename''</code> {{para|alt''n''|''Alt text''}} <code>|''Caption''</code>
 
Where:
: <code>|File:''Filename''</code> – the image's file name. Either <code>File:</code> or <code>Image:</code> prefix may be used
: {{para|Alt''n''}} – alt attribute: {{para|alt1}} for the first image, {{para|alt2}} for the second image, etc
:: <code>''Alt text''</code> – the [[w:Wikipedia:Alternative text for images|alternative text]] for the image, used by visually impaired or other readers who cannot see the image clearly. If omitted, the image's alt text will be blank.
: <code>|''Caption''</code> – the caption under the image
 
=== Optional parameters ===
 
These parameters apply to the gallery:
 
: {{para|title}} – The gallery's title
: {{para|align}} – The alignment of the gallery on the page, left (default), center, or right; ignored when {{para|state}} is set
: {{para|footer}} – Small, right-aligned text below the images
: {{para|style}} – [[w:Cascading Style Sheets|CSS]] style directives for the whole gallery (see [[Wikipedia:Help:Cascading Style Sheets]])
: {{para|class}} – HTML class for the whole gallery
: {{para|state}} – Sets the default state of collapsible galleries; use {{para|state|expanded}} or {{para|state|collapsed}}; collapsible galleries occupy the full page width
: {{para|mode}} – Sets the mode used by the inner gallery tag.  Common values include {{para|mode|packed}} and {{para|mode|nolines}} (see [[Wikipedia:Help:Gallery tag]] for more options)
These parameters apply to all of the images in the gallery:
: {{para|noborder}} – Cancel the border surrounding the images, use {{para|noborder|yes}} to set.
: {{para|whitebg}} – Cancel the white background surrounding the images, use {{para|whitebg|no}} to set.
: {{para|height}} – Maximum height of each image. If this parameter is not included, defaulting to 180 pixels.
: {{para|width}} – Maximum width of each image, defaulting to 180 pixels.
: {{para|captionstyle}} – [[w:Cascading Style Sheets|CSS]] style directives for the captions (see [[Wikipedia:Help:Cascading Style Sheets]])
: {{para|showfilename}} – Allow to show the file name of each image, use {{para|showfilename|yes}} to set.
 
The image's original ratio of width to height cannot be modified by {{para|width}} or {{para|height}} – a rectangular image will not be made square if {{para|width}} and {{para|height}} are set to the same value.
 
== Example ==
{{Gallery
|title=Photographs
|width=150
|perrow=4
|1=File:Oost amsterdam cs.JPG|2=Oostzijde Centraal Station
|3=File:AMS central station 3.jpg|4=[[Stationsplein (Amsterdam)|Stationsplein]] Amsterdam
|5=File:Asd cs afstand.JPG|6=Het station vanaf de [[Oude Kerkstoren]]
|7=File:Amsterdam Centraal oostzijde.jpg|8=Het station vanuit het oosten
|9=File:Oost amsterdam cs.JPG|10=Oostzijde Centraal Station
|11=File:AMS central station 3.jpg|12=[[Stationsplein (Amsterdam)|Stationsplein]] Amsterdam
|13=File:Asd cs afstand.JPG|14=Het station vanaf de [[Oude Kerkstoren]]
|15=File:Amsterdam Centraal oostzijde.jpg|16=Het station vanuit het oosten
|17=File:Oost amsterdam cs.JPG|18=Oostzijde Centraal Station
|19=File:AMS central station 3.jpg|20=[[Stationsplein (Amsterdam)|Stationsplein]] Amsterdam
|21=File:Asd cs afstand.JPG|22=Het station vanaf de [[Oude Kerkstoren]]
|23=File:Amsterdam Centraal oostzijde.jpg|24=Het station vanuit het oosten
|25=File:Oost amsterdam cs.JPG|26=Oostzijde Centraal Station
|27=File:AMS central station 3.jpg|28=[[Stationsplein (Amsterdam)|Stationsplein]] Amsterdam
|29=File:Asd cs afstand.JPG|30=Het station vanaf de [[Oude Kerkstoren]]
|31=File:Amsterdam Centraal oostzijde.jpg|32=Het station vanuit het oosten
|33=File:Oost amsterdam cs.JPG|34=Oostzijde Centraal Station
|35=File:AMS central station 3.jpg|36=[[Stationsplein (Amsterdam)|Stationsplein]] Amsterdam
|37=File:Asd cs afstand.JPG|38=Het station vanaf de [[Oude Kerkstoren]]
|39=File:Amsterdam Centraal oostzijde.jpg|40=Het station vanuit het oosten
}}
 
=== Sourcecode of example ===
<pre>
{{Gallery
|caption=Photographs
|width=150
|perrow=4
|Image:Oost_amsterdam_cs.JPG|Oostzijde Centraal Station
|Image:AMS_central_station_3.jpg|[[Stationsplein (Amsterdam)|Stationsplein]] Amsterdam
|Image:Asd_cs_afstand.JPG|Het station vanaf de [[Oude Kerkstoren]]
<!-- ... -->
}}
</pre>
 
The source and idea for this template come from [[w:Template:Gallery]].
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
[[Category:Gallery templates|{{PAGENAME}}]]
}}</includeonly>

Latest revision as of 09:17, 14 October 2023

This template provides advanced gallery building functionality (fine-tuned formatting control).

This template displays a gallery of images in an array, left-to-right in rows. Global parameters |width= and |height= control the size of all images in the gallery. The number of images per row is based upon the image width parameters and the width of the screen. The number of images per row can change when the user resizes the window.

{{Gallery
| title        = 
| align        =
| footer       =
| style        =
| class        =
| state        =
| height       =
| width        =
| captionstyle =
| File:
 | alt1=
 | Write a caption here
| File:
 | alt2=
 | Write a caption here
| File:
 | alt3=
 | Write a caption here
| File:
 | alt4=
 | Write a caption here
| File:
 | alt5=
 | Write a caption here
}}

Parameters

For each image

Specify a line of the following form for each image.

|File:Filename |altn=Alt text |Caption

Where:

|File:Filename – the image's file name. Either File: or Image: prefix may be used
|Altn= – alt attribute: |alt1= for the first image, |alt2= for the second image, etc
Alt text – the alternative text for the image, used by visually impaired or other readers who cannot see the image clearly. If omitted, the image's alt text will be blank.
|Caption – the caption under the image

Optional parameters

These parameters apply to the gallery:

|title= – The gallery's title
|align= – The alignment of the gallery on the page, left (default), center, or right; ignored when |state= is set
|footer= – Small, right-aligned text below the images
|style=CSS style directives for the whole gallery (see Wikipedia:Help:Cascading Style Sheets)
|class= – HTML class for the whole gallery
|state= – Sets the default state of collapsible galleries; use |state=expanded or |state=collapsed; collapsible galleries occupy the full page width
|mode= – Sets the mode used by the inner gallery tag. Common values include |mode=packed and |mode=nolines (see Wikipedia:Help:Gallery tag for more options)

These parameters apply to all of the images in the gallery:

|noborder= – Cancel the border surrounding the images, use |noborder=yes to set.
|whitebg= – Cancel the white background surrounding the images, use |whitebg=no to set.
|height= – Maximum height of each image. If this parameter is not included, defaulting to 180 pixels.
|width= – Maximum width of each image, defaulting to 180 pixels.
|captionstyle=CSS style directives for the captions (see Wikipedia:Help:Cascading Style Sheets)
|showfilename= – Allow to show the file name of each image, use |showfilename=yes to set.

The image's original ratio of width to height cannot be modified by |width= or |height= – a rectangular image will not be made square if |width= and |height= are set to the same value.

Example

Sourcecode of example

{{Gallery
|caption=Photographs
|width=150
|perrow=4
|Image:Oost_amsterdam_cs.JPG|Oostzijde Centraal Station
|Image:AMS_central_station_3.jpg|[[Stationsplein (Amsterdam)|Stationsplein]] Amsterdam
|Image:Asd_cs_afstand.JPG|Het station vanaf de [[Oude Kerkstoren]]
<!-- ... -->
}}

The source and idea for this template come from w:Template:Gallery.