This page is protected against editing.

Template:F

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Sample.svg

Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:F/doc.

Establishes a link to the file whose name is given in parameter #1 and displays the name without the prefix "File:".

  • Instead of the file name, any text given in parameter #2 can be displayed.
  • The image can be displayed at any size inline, after the name.
For more details go to standard usage.


Additional possibilities:

  • It is possible to display the image left of the name to allow better text alignment when arranging in several lines, see Option "l"
  • It is possible to show the file name below of ("under") the displayed image, as with the [[File:...]] function, see Option "u".
  • It is possible to avoid the link and display the plain name of parameter #1 (or parameter #2), see Option "n".
  • It is possible to avoid any display of the name but display the image only, see Option "Z".
  • It is possible to display the image in the horizontal center of the line, see Option "c".
  • The displayed image can be surrounded by a border, see Option "b".
For more details go to extended usage.

Usage

{{F |1= }}

Only Parameters 1, 2 and 3 are fixed, all other options are not fixed to any parameter position

Template parameters

ParameterDescriptionDefaultStatus
1File NameName of the file, with or without namespace; or * on the file description page/talk page
underscores contained in the filename are replaced by spaces.
emptyrequired
2Display NameAny text, default is the file name (parameter #1). If there is no alternate text the parameter #2 instead can hold the first option.File Nameoptional
3
d
Image sizeNumeric value for the image size in px. The picture is displayed inline in this size; 0 means: don't display
Parameter d has precedence over 3; d= or d=- suppresses any display.
emptyoptional
4OptionOption: b (lowercase B) to draw a border around the displayed pictureemptyoptional
5OptionOption: l (lowercase L) to display the image left of the file name
Option: r (lowercase R) to display the image to the rightmost
Option: c (lowercase C) to display the image in the center
Option: u (lowercase U) to display the image above
Option: Z (uppercase Z) to suppress the display of the file name
right
of the
filename
optional
6OptionOption: n (lowercase N) to display the name not-linking to the fileemptyoptional
7OptionOption: + to display the namespace prefix “File:” as part of the link
Option: - to display the namespace prefix “File:” not as part of the link
emptyoptional
8File Function LetterDifferent functions can be performed, see File Function Letters.emptyoptional
tSeparatorThe separator can be any text string, used between displayed file name and displayed image
Use uppercase T= to precede the string with a space (other function with option "u")
 optional
pPrefixa prefix to be written in advance; e.g. p=<br/> for a new lineemptyoptional
lInterwiki & interlanguage linkFor interlanguage linking with ISO 639 codes if the file is in another Wikipedia and for Interwiki linking if the file is in a Wikimedia sister project, see parameter "l".emptyoptional
langSVG language switchlanguage code (ISO 639), to display a translated version when the SVG file contains translations using SVG ‎<switch> elements, see Parameter "lang".emptyoptional
linkLinkenables to link to somewhere elseemptyoptional
byAuthorcan be used to display the user who created the file, see parameter "by"emptyoptional
mAuthor modification codemodification of the "by"-user, e.g. c, d, n, t, w, wt,
see parameter "m"
emptyoptional
Template data
<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.

Discussion
There is an ongoing discussion about that matter. Feel invited to comment if you are experienced in either way, your time permits and if you like to share your opinion or to make a suggestion.


Wikipedia's help about TemplateDataCommons-specific information

Establishes a link to the file whose name is given in parameter #1 and displays the name without the prefix "File:".

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
File Name1

Name of the file, with or without namespace; or “*”. Underscores contained in the filename are replaced by spaces.

Filerequired
Display Name2

Any text. If there is no alternate text parameter #2 instead can hold the first "option".

Default
The file name (parameter #1).
Lineoptional
Image size3 d

The picture is displayed inline in this size.

Numberoptional
''Option''4

b (lowercase B)
Draw a border around the displayed picture

Suggested values
b
Stringoptional
''Option''5

l (lowercase L)
Display the image to the <u>l</u>eft of the file name
r (lowercase R)
Display the image to the <u>r</u>ight of the file name
c (lowercase C)
Display the image in the center
u (lowercase U)
Display the image <u>u</u>nder (below of) the file name
Z (uppercase Z)
Suppress the display of the file name

Suggested values
l r c u
Default
right<br />of the<br />filename<br />
Stringoptional
''Option''6

n (lowercase N)
Display the name not-linking to the file

Suggested values
n
Stringoptional
''Option''7

+
Display the namespace prefix “File:” as part of the link
-
Display the namespace prefix “File:” outside the link

Suggested values
+ -
Stringoptional
File Function Letter8

Different functions can be performed.

Stringoptional
Authorby

can be used to display the user who created the file

Useroptional
Interwiki & interlanguage linkl

For interlanguage linking with ISO 639 codes if the file is in another Wikipedia and for Interwiki linking if the file is in a Wikimedia sister project.

Stringoptional
SVG language switchlang

language code (ISO 639), to display a translated version when the SVG file contains translations using SVG <switch> elements.

Stringoptional
Linklink

enables to link to somewhere else

Page nameoptional
Author modification codem

modification of the "by"-user, e.g. "m=c", "m=d" or "m=n", "m=t", "m=w" or "m=wt"

Unknownoptional
Prefixp

A prefix to be written in advance; e.g. “p=<br/>” for a new line

Lineoptional
Separatort

Used between the displayed file name and displayed image. Use uppercase “T=” to precede the string with a space.

Default
&nbsp;
Lineoptional

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

See also

Some templates using {{F}} can display an unlimited number of files, names and/or images, with possibly other display names and many other modifying parameters:

  • {{ G }} – displays a gallery of an unlimited number of files
  • {{ File }} – displays horizontally an unlimited number of files, after the internationalized text "File:"
  • {{ Filelist }} – displays horizontally an unlimited number of files: {{ Filelistfilename 1filename 2filename 3 }}
  • {{ Other versions }} – to display vertically an unlimited number of files, e.g. in the Other versions= field
  • {{ Derived from }} – displays vertically an unlimited number of files, after text
  • {{ Derivative versions }} – displays vertically an unlimited number of files, after text
  • {{Lang gallery}}, {{Lgallery}}, {{Svg lang}} – can display an unlimited number of translations, in gallery style

Localization

This template is not intended to be localized.

Standard usage

Parameter #1 (File Name) is the only parameter which is required. It can only hold the filename, with or without "File:", or "*" on the file description page – the displayed file name is without "File:". All underscores ("_") contained in the filename are replaced by spaces. Parameter values "Filename.ext" or "File:Filename.ext" may be used, but not "[[File:Filename.ext]]".

Parameter #2 (Display Name) can hold an alternate text (instead of the file name) which can only be passed with this parameter. Underscores ("_") contained in the display name are displayed. If there is no given alternate text parameter #2 can instead hold the first option.

Parameter #3 (Image size) can hold the displayed image size which can be passed with either 3= or d=. By default the image is displayed right of the file name; this can be changed to left with option "l" or to uppper with option "u". Formats for the image size are e.g. 96 or x64 or 60x16.

  • It is not possible to display images of other Wikipedias - only when the files are stored in the Commons !
Examples
Syntax Code Result Note
{{ Ffile name }} {{F|SVG_Simple_Icon.svg}}
{{F|File:SVG_Simple_Icon.svg}}
SVG Simple Icon.svg is the simplest form; it displays the file name as a link to the file.
{{ Ffile nameany text }} {{F|SVG_Simple_Icon.svg|example}} example displays the text string of the 2nd parameter as a link to the file.
{{ Ffile namesize }} {{F|SVG_Simple_Icon.svg|d=16}} SVG Simple Icon.svg displays first the file name, and then the image with a size in px.
{{ Ffile nameany textsize }} {{F|SVG_Simple_Icon.svg|SVG|16x16}} SVG is the same but any text is displayed instead of the file name.

Note:

  • When parameter #1 contains an asterisk (the value * ) instead of the file name, that will be replaced by the {{PAGENAME}}; this is possible only in the file namespace.


Extended usage

Parameters #4 to #7 – Options

 
Other than parameters #1, #2 and #3 the “options” (b, c, n, l, r, u, Z, +, -) are not fixed to a parameter position, or to a special sequence.

Every one of these options can as well be specified with every parameter #4 to #7. When no display of the image is required, an option can also be specified with parameter #3; when parameter #2 is not needed for a display text, the option code can even be specified with parameter #2 (to distinguish a text of one character from a one-character-code, the text may need to be expanded e.g. with <nowiki/>).
{{ Ffile nameany textsizebln }} is an example for usage of these formatting characters - the sequence does not matter.
There are the following options:

Option "b"
  • b draws a border around the image. This can be useful to show the extensions of an image with transparency.
Option "c"
  • c displays the image in the center of the line (this option may collide with the File Function Letter "C", dependent on the other used parameters).
Option "l"
  • l displays the image left of the name. This option allows a better formatting, e.g. when more files are displayed in a list and the file names are of different length:
    {{ Ffile namesizel }} (or {{F|file name|l|size}}) to display the file left of the name.
Option "r"
  • r displays the image to the right (has precedence over code l). E.g.
    {{ FSq3 blackredgold.svgr32T = → → → }} will show rightmost 0 Sq3 blackredgold.svg → → →
Option "u"
  • u: To show the file name below of ("under") the displayed picture, as with the [[File:...]] or the gallery function.

With the parameter "t" a pixel distance (left padding) can be specified. Example: {{ FSolid yellow.svgu64 }}{{ FSolid lime.svgu64t = 3 }}{{ Clr }}

000 Can be combined with other options, e.g. option r
Option "Z"
  • Z: When an image should be displayed without showing the file name, this can be achieved by setting the character "Z". Parameter #1 specifies the file name, parameter #3 the size; therefore Z can be set by either parameter #4 to #7 or the not needed parameter #2. Of course it is of no use to combine Z with n, l or r but it won't do any harm.
    E.g. the sequence
    {{F|Rzz 10.svg|Z|10|b}}{{F|Rzz 10.svg|b|16|Z}}{{F|Rzz 10.svg||10|Z|b}} will show
Option "n"
  • n: Independent whether the image is displayed or not, the parameter n let display plain text instead of the link. This is sometimes useful for better formatting.
Note: n can as well be specified with every parameter #4 to #7. When no display of the image is required, n can also be specified with parameter #3; when parameter #2 is not needed for a display text, n can even be specified with parameter #2 (to distinguish a text of one character from a one-character-code, the text may need to be expanded e.g. with <nowiki/>).
{{ Ffile nameany textsizebln }} is an example for usage of these formatting characters - the sequence does not matter.
Option "+"
  • +: Independent whether the image is displayed or not, the plus sign can be used to prefix the file name display with the namespace.
No translation occurs, "File:" is used.
{{ FExample.svg+12 }} displays File:Example.svg, the name space as a part of the link.
Option "-"
  • -: With the minus sign the name space is not a part of the link:
    {{ FExample.svgl12- }} displays File:Example.svg.
The name space option seems misleading and not useful with a display name (parameter #2) but it is possible to define it that way:
{{ FExample.svgTest12+ }} will display File:Test
If as well a + and a - sign are mistakenly defined, the - is ignored.
Note: Some odd combinations of + or - with n are currently not working properly, esp. with n as parameter #3. Use another, better working parameter sequence when a misinterpretion occurs.
More options
  • The four parameters 11 to 14 can be used to specify extended options , as vertical options e.g. |11=baseline or |14=text-bottom.
Other options can as well be specified this way, e.g. |12=border|13=center
Examples
Code Result Note
{{ F }} 0 no name without parameter #1: error display & categorization
{{ FYes_check.svg }} Yes check.svg only link
{{ FYes check.svgn }} Yes check.svg only name - without link
{{ FYes check.svg16b }} Yes check.svg bordered
{{ FYes check.svg16l }} Yes check.svg 0 left of name (as in "other versions" of File:Symbol unrelated.svg.)
{{ FYes check.svg16n }} Yes check.svg:  no link (as in "other versions" of File:Arrow-C.svg.)
{{ FYes check.svg16r }} Yes check.svg
rightmost display, with file name
{{ FYes check.svg16rZ }}
rightmost display of image, without file name
{{ FYes check.svg16cZ }} 1=Yes check.svg;

2=; 3=16; 4=c; 5=Z; Y=3;c=3;

P=F;
|| centered display of image, without file name

Notes:

  • The options can as well be written immediately with parameter #2 when no text is passed:
    • {{F|Yes check.svg||n}} is equivalent to {{F|Yes check.svg|n}},
    • {{F|Yes check.svg||16|b}} is equivalent to {{F|Yes check.svg|b|16}}
    • {{F|Yes check.svg||16|r|Z}} is equivalent to {{F|Yes check.svg|r|16|Z}} and so on.
  • Also the sequence does not matter:
    • {{F|X.jpg||16|b|l|n}} is equivalent to {{F|X.jpg||16|n|l|b}}.
    • {{F|X.jpg||16|4=b|5=l}} is equivalent to {{F|X.jpg||16|4=l|7=b}}
  • "b", "c", "n", "l", "r" or "u" may even be coded at the position of parameter #3 when no image size is specified there.
  • When it is required to display a text of one character equal to "b", "n", "l", "r", "u", "+", "-", "Z" or a FFL it can be distinguished from such a code by an expansion, e.g. with ‎<nowiki />.

Parameter "t" – Separator

t=: When the image is displayed either left or right of the displayed file name, with t= any text can be defined to separate the two items. It will replace the default separator :&nbsp; (or &nbsp; with option l).
With the Option: u the parameter "t" can specify a pixel distance (left padding) making the display wider.

Parameter "l" – Interwiki & interlanguage linking

The named parameter l= enables Interwiki access and interlanguage access.

Interwiki links or links to sister projects are e.g.

Interlanguage links are via ISO 639 codes

Examples

Note:

  • Files in any Wikipedia, Wikisource, Wikibooks etc can be addressed, but it is not possible to display images from outside of Commons due to technical restrictions.

Parameter "lang" – SVG language switch

The named parameter lang= allows to use the language switch option:

Example

The file France Population Pyramid-2010.svg contains many languages. With {{F|France Population Pyramid-2010.svg|Diagram rendered in {{#language:ru|en}}|250|l|lang=ru|t=<br />}} the translated versions can be shown:


Diagram rendered in Arabic

Diagram rendered in Japanese

Diagram rendered in Russian

Note: The displayed names are linking to the default language version.

Parameter "by" – Author

Examples
{{ FYes check.svgb12by = Gmaxwell }} Yes check.svg by Gmaxwell
{{ FX mark.svg-by = {{ut|Anybody||de}} of {{wd}} }} File:X mark.svg by Anybody of de:Wp
{{ F#RR.svg-22by = <>nobody }} File:3RR.svg by nobody
{{ FYes check.svg/Gmaxwell }} Yes check.svg by Gmaxwell

Note:

  • Usernames prefixed by either one of & ( . < [ { are displayed-as-they-are without link, and & ( . < doubled, or () <> [] {}, are then removed.
  • Instead of the |by= a |/ can be enough to specify a user. While By is used by several templates, the abbreviation "|/" is only possible with Template:F.
  • Some Lua-based iteration templates (e.g. Based, Filelist, Other versions, Derived from) can do it with only one parameter: filename.jpg / username, thanks to Lua
    instead of the |/ only / is needed. Template:{{F}} avoids module invoked string operations which makes it necessary to use two parameters: filename.jpg|/username.
  • But one of the Lua-based templates, e.g. {{Fl}}, can be used for that abbrevition possibility, {{ FlDngerstff.svg/Histolo2d = 64 }} expands to Dngerstff.svg by Histolo2

Parameter "m" – Author modification code

m=: When a user name (e.g. of the creator) is displayed because of the parameter "by", any needed modification of {{U}} to either {{Ut}}, {{Uw}} or {{Uwt}} is possible with m=t, m=w, m=wt.

Examples
{{ FYes check.svg/Gmaxwellm = t }} Yes check.svg by Gmaxwell
{{ FExample.svgby = Examplem = w }} Example.svg by Example

Parameter #8 – File Function Letters

This option is completely different from the description above, a value is returned instead of displaying something. By invoking the Module:File various functions can be performed. While parameter #1 specifies the file, the File Function Letter must be specified only with parameter #2 (or #1 when transcluded from the file page).
Such an FFL has precedence, additional parameter settings are ignored for most of the File Function Letters. Exception: "M".
Except of the mere string operations F, X and U, for files outside the commons none of the File Functions can be performed.

FFL function returned result example code result
0F file name name without extension   {{F|F}} {{F|Peacedovei….svg|F}} Peacedoveingreencircle
0L link name name without extension but linked {{F|Peacedovei….svg|L}} Peacedoveingreencircle
0M file name name stripped left and/or right (only possible with the "M" as parameter 1) - - -
0X extension extension without name {{F|Peacedovei….svg|X}} file svg file
{{uc:{{F|Peacedovei….svg|X}}}} file
0Note: {{uc:}} forcing text string to uppercase.
SVG file
0U extension extension as-it-is, case sensitive {{F|Peacedovei….svg|U}} graphic svg graphic
0I ifexist "true" if file exists {{F|Peacedovei….svg|I}} true
0C count number of file pages {{F|Peacedovei….svg|C}} 1
0D date work date, formatted yyyy-mm-dd {{F|Peacedovei….svg|D}} - none -
0W width width in pixel {{F|Peacedovei….svg|W}} ×
{{F|Peacedovei….svg|H}} pixels
714 × 729 pixels
0H height height in pixel
0V valid? error count from W3C validation {{F|Peacedovei….svg|V}} - none -
0S size file size in bytes {{F|Peacedovei….svg|S}} bytes 5819 bytes
0P page size size of file description page in bytes {{F|Peacedovei….svg|P}} bytes 2,448 bytes
0G gallery gallery style display, see below {{F|Peacedoveingreencircle.svg|G}}

Note:

  • When a file name is enough descriptive that it could be used in the file description without alteration, the function {{F|F}} can be used, e.g. |description={{en|{{F|F}}.}}
This function cannot alter the filename, but stripping of X characters left with +X, and/or of Y characters right with -Y, is possible with FFL "M":
to display just "Panorama" of "1623 Panorama 2.jpg" use {{F|M|+5|-2}}. See examples Gabjae Folk Museum 9.jpg or Equiangular pentagon 00.svg.
  • On the other hand it can be a useful abbreviation, to specify the own name with {{F|*}} - a short form of {{F|{{PAGENAME}}}}.
Examples
  • {{F|Buddhist rainbow flag.svg|Buddhist flag|32|l|t=  file name: }} ({{uc:{{F|Buddhist rainbow flag.svg|X}}}} file, nominally {{F|Buddhist rainbow flag.svg|W}} × {{F|Buddhist rainbow flag.svg|H}} pixels, file size: {{F|Buddhist rainbow flag.svg|S}} bytes; description: {{F|Buddhist rainbow flag.svg|P}} bytes.) gives the following:
  file name: Buddhist flag (SVG file, nominally 450 × 300 pixels, file size: 553 bytes; description: 4,109 bytes.)
  • ''{{subst:F|{{PAGENAME}}|F}}'' in the description of the above file will give: Buddhist rainbow flag; a short form can be used:

File Function Letter "G" – Gallery Style

With the File Function Letter "G" a gallery-like display can be achieved. Different possibilities exist:

{{ Ffile nameG }} like <gallery> file name | file name </gallery> centered
{{ Ffile name0G }} like <gallery> file name </gallery>
{{ Ffile namecaptionG }} like <gallery> file name | caption </gallery> centered
{{ Ffile nameGcaption }} like <gallery> file name | caption </gallery>

The minus sign can be used to display the name space "File:"

{{ Ffile nameG.- }} like <gallery> file name | File:file name </gallery> centered
{{ Ffile name-.G }} like <gallery> file name | File:file name </gallery>

Notes:

  • The gallery style function of Template:F can be useful to display just only one file.
  • Display of more files is possible, but it is easier to do with the gallery template:G, where the file names can be separated also with linefeeds, or/and with | (pipes).
Examples
with Template:{{F}} with Template:{{G}}

{{F|Pink check.svg|
Purple check.svg
Yellow check.svg
Red check.svg
|G|44}}

{{G|Pink check.svg

Purple check.svg
Yellow check.svg
Red check.svg|d=44}}

another example with caption:

{{F|
Pink check.svg|caption 1
Purple check.svg{{!}}capt 2
Yellow check.svg{{!}}capt 3
Red check.svg{{!}}capt 4
|G|32}}

{{G|
Pink check.svg|capt 1
Purple check.svg|capt 2
Yellow check.svg|capt 3
Red check.svg|capt 4|w=32}}

Iterated use of {{F}}

Several templates (as {{Attribs}}, {{Derived from}}, {{Derivative versions}}, {{File}}, {{Filelist}}, {{Iterate}}, {{Own based}}, {{Other versions}}, ...)
can use the template {{F}} with all its options iterative.


With: {{ Iterate
p1 = 32p2 = Z
Pink check.svg
Purple check.svg
Yellow check.svg
White check.svgb
Red check.svg }}
(default for t=F and n=2)
these five files are shown:


With: {{ Filelist
d = 32o = Zc = nq4 = b
Pink check.svg
Purple check.svg
Yellow check.svg
White check.svg
Red check.svg }}
the same display is shown:

See also