Template:Flag/sandbox: Difference between revisions
(use module) |
(No difference)
|
Revision as of 01:34, 7 May 2020
Script error: No such module "flag/sandbox".
This is the template sandbox page for Template:Flag (diff). See also the companion subpage for test cases. |
This template is used on many pages. To avoid large-scale disruption and unnecessary server load, any changes to this template should first be tested in its /sandbox or /testcases subpages or in your own user subpage. The tested changes can then be added to this page in one single edit. Please consider discussing any changes on the talk page before implementing them. |
This template is used to display a small flag icon next to a wikilinked country name. It is related to the {{flag icon}}, {{flag country}} and {{flagu}} templates, but offers more options in terms of the text string displayed.
See Wikipedia:WikiProject Flag Template for the main documentation/discussion page for the flag templates system.
Usage
{{flag|country identifier|optional variant|name=alternative text string|size=maximum width and/or height of the flag image}}
- country identifier is the common name of the country (e.g. "United States"), a common alias (e.g. "US"), or a standard country code such as those listed at ISO 3166-1 alpha-3
- variant is an optional second parameter that can be used to display a flag variation, such as a historical flag. The list of variants for each country is documented on the appropriate template page, such as Template:Country data Germany
- alternative text string, this optional value, specified by the name parameter, is used to display alternative text
- size, this optional value is specified by the size parameter, and is used to specify the maximum width and/or height of the flag image. This parameter is specified using standard image syntax.
See the prefix index for the templates latently called by this one.
Examples
Wiki markup | Displays | Notes | |
---|---|---|---|
{{flag|United States}} |
Template:Country data United States | Note that all instances link to United States. | |
{{flag|US}} |
Template:Country data US | ||
{{flag|USA}} |
| ||
{{flag|Germany}} |
Germany | All three instances link to Germany. In addition to the ISO country codes, those used by FIFA, IOC, etc. are also supported. | |
{{flag|DEU}} |
Template:Country data DEU | ||
{{flag|GER}} |
GER | ||
{{flag|Germany|empire}} |
Germany | Flag variations can be used with either country names or country codes. | |
{{flag|DEU|empire}} |
Template:Country data DEU | ||
{{flag|CAN|name=Canadian}} |
Template:Country data CAN | The name parameter can be used to change the display string but keep the link to the correct article. | |
{{flag|Canada|1957|name=Canadian}} |
Template:Country data Canada | The name parameter can also be used when flag variants are specified. | |
{{flag|Texas}} |
Template:Country data Texas | Flags are also available for several sub-national and multi-national entities such as US states, Canadian provinces, and the European Union. A complete list can be found at Category:Country data templates. | |
{{flag|British Columbia|name=BC}} |
BC | ||
{{flag|EU}} |
Template:Country data EU | ||
{{flag|Switzerland|size=14px}} |
Switzerland | The size parameter can be used to control the image dimensions. 23×15px is the default size for most countries (some entities have a different default size). | |
{{flag|Switzerland|size=28px}} |
Switzerland | ||
{{flag|Nepal}} |
Nepal | Some flags are non-quadrilateral. |
Alternatives to avoid Wikipedia's Post-expand include size limit
Pages with many flags may come close to or exceed Wikipedia's Post-expand include size limit. In these cases consider using modules or module-wrapper templates instead:
- For many countries, using the country code as the template name will act as a wrapper for Module:Flagg: For example,
{{flag|''USA''}}
can be replaced with{{USA}}
, which has an include size that is about 15% smaller. - {{#invoke:flag||}} is a wrapper for Module:Flagg that can further reduce sizes when invoked directly. For basic use,
{{flag|country}}
can be replaced with{{#invoke:flag||country}}
which has an include size that is about half.
TemplateData
This is the TemplateData documentation for this template used by VisualEditor and other tools.
Flag
This template displays a small flag icon next to a wikilinked country name
Parameter | Description | Type | Status | |
---|---|---|---|---|
Country identifier | 1 | Common name of the country (e.g. 'United States'), a common alias (e.g. 'US'), or a standard country code | String | required |
Variant | 2 variant | Identifies a flag variant to be used instead of the standard flag, e.g. 1815 | String | optional |
Alternative text | name | Display alternative text instead of the standard country name | String | optional |
Maximum dimension | size | The maximum width or height, specified via standard 'extended image syntax' (e.g. x30px) | String | optional |
See: Wikipedia:Extended image syntax.
See also
Template | Description | Example |
---|---|---|
{{Coat of arms}} | displays coat of arms image | Template:Coat of arms |
{{Flag country}} | always expands the link text to the full country name | Germany |
{{Flagu}} | does not link the country name | Germany |
{{Flag icon}} | displays the flag only, linked to the country name | |
{{Flag decoration}} | displays an unlinked flag icon only | |
{{Flagc}} | links the flag image to its description page | Germany |
{{Flaglist}} | aligns country names correctly in vertical lists (see that template's documentation) | Germany |
{{Flag team}} | adds country code in parentheses after linked country name | Germany (GER) |
{{Flag athlete}} | displays the flag and another name, followed country name or code | Template:Country flagbio |
{{Flag medalist}} | displays the flag and a name, above linked country name and code | Dirk Nowitzki Germany |
See Wikipedia:WikiProject Flag Template#List for a longer list of flag templates.
Multi-sport templates
Output style → | Country name | Country name (code) | Athlete (country code) | Athlete Country Name | Country code |
---|---|---|---|---|---|
Olympic Games | {{Flag IOC}} | {{Flag IOC team}} | {{Flag IOC athlete}} | {{Flag IOC medalist}} | {{Flag IOC short}} |
Other games | {{Flag IOC 2}} | {{Flag IOC 2 team}} | {{Flag IOC 2 athlete}} | {{Flag IOC 2 medalist}} | {{Flag IOC 2 short}} |
Paralympic Games | {{Flag IPC}} | {{Flag IPC team}} | {{Flag IPC athlete}} | {{Flag IPC medalist}} | {{Flag IPC short}} |
Pan American | {{Flag PASO}} | {{Flag PASO team}} | {{Flag PASO athlete}} | {{Flag PASO medalist}} | |
Parapan American | {{Flag PPASO}} | ||||
Commonwealth | {{Flag CGF}} | {{Flag CGF team}} | {{Flag CGF athlete}} | {{Flag CGF medalist}} | |
Southeast Asian | {{Flag SEAGF}} | {{Flag SEAGF team}} | {{Flag SEAGF athlete}} | {{Flag SEAGF medalist}} | |
World Games | {{Flag IWGA}} | ||||
Central American and Caribbean Games | {{Flag CAC}} | ||||
Asian Games | {{Flag OCA}} | ||||
European Games | {{Flag EOC}} | ||||
African Games | {{Flag AFOC}} | ||||
Mediterranean Games | {{Flag CIJM}} | ||||
Summer Universiade | {{Flag FISU}} | ||||
"Nation at Championships"-style | {{Flag link team}} | ||||
Generic | TFlag | {{Flag team}} | {{Flag athlete}} | {{Flag medalist}} | |
Generic (variant) | {{Flag link}} | {{Flag link athlete}} | {{Flag link medalist}} |
See also
Module-based versions which can be used to reduce the post-expand include size on pages that are near or exceed the limit.
- Template:Flagg a version which implements Module:Flagg
- Module:Flag also works with Module:Flagg