Difference between revisions of "Template:F"
Mediawiki>Sarang m (test) |
m (1 revision imported) |
Latest revision as of 07:59, 24 January 2022
Note: This template is used on a lot of pages. In order not to put too much load on the servers, edits should be kept to a bare minimum. Please discuss proposed changes on the talk page first.
|
30px | This template uses Lua: |
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 file itself (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 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, see Option "Z".
- The displayed image can be surrounded by a border, see Option "b".
- For more details go to extended usage.
Usage
{{F |1= }}
Template parameters
Parameter | Description | Default | Status | |
---|---|---|---|---|
1 | File Name | Name of the file, with or without namespace; or * underscores contained in the filename are replaced by spaces. | empty | required |
2 | Display Name | Any text, default is the file name (parameter #1). If there is no alternate text the parameter #2 instead can hold the first option. | File Name | optional |
3 | Image size | Numeric value for the image size. The picture is displayed inline in this size | empty | optional |
4 | Option | Option: b (lowercase B) to draw a border around the displayed picture | empty | optional |
5 | Option | Option: l (lowercase L) to display the image left of the file name Option: r (lowercase R) to display the image to the rightmost | empty | optional |
6 | Option | Option: n (lowercase N) to display the name not-linking to the file | empty | optional |
7 | Option | Option: + to display the namespace prefix “File:” as part of the link Option: - to not display the prefix “File:” as part of the link | empty | optional |
8 | Option | Option: Z (uppercase Z) to suppress the display of the file name | empty | optional |
9 | File Function Letter | Different functions can be performed, see File Function Letters. | empty | optional |
t | Separator | The separator can be any text string, used between displayed file name and displayed image Use uppercase T= to precede the string with a space | | optional |
p | Prefix | a prefix to be written in advance; e.g. p=<br/> for a new line | empty | optional |
l | Interwiki & interlanguage link | 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, see parameter "l". | empty | optional |
lang | SVG language switch | language code (ISO 639), to display a translated version when the SVG file contains translations using SVG <switch> elements, see Parameter "lang". | empty | optional |
link | Link | enables to link to somewhere else | empty | optional |
by | Author | can be used to display the user who created the file, see parameter "by" | empty | optional |
u | Author modification code | modification of the "by"-user, e.g. t , w , wt ,see parameter "u" | empty | optional |
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
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 Newly created template documentation and imports Wikipedia's help about TemplateData • Commons-specific information Unexpected property "params.4.suggestedvalues". |
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
⧼Seealso⧽
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:
- {{ File | … }} – displays horizontally an unlimited number of files, after the internationalized text "File:"
- {{ Filelist | … }} – displays horizontally an unlimited number of files: {{ Filelist | filename 1 | filename 2 | filename 3 | … }}
- {{ Other versions }} – to display vertically an unlimited number of files, e.g. in the
Other versions=
field - {{ Derived from | … }} – displays vertically, after text
- {{ Derivative versions | … }} – displays vertically, after text
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:" – the displayed file name is in both cases without "File:". Underscores ("_") contained in the filename are replaced by spaces.
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 only be passed with this parameter. By default the image is displayed right of the file name. This could be changed with option "l". 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 |
---|---|---|---|
{{ F | file 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. |
{{ F | file name | any text }} | {{F|SVG_Simple_Icon.svg|example}} | example | displays the text string of the 2nd parameter as a link to the file. |
{{ F | file name | | size }} | {{F|SVG_Simple_Icon.svg||16}} | SVG Simple Icon.svg: 16px | displays first the file name, and then the image with a size in px. |
{{ F | file name | any text | size }} | {{F|SVG_Simple_Icon.svg|SVG|16x16}} | SVG: 16x16px | 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 #8 – Options
In comparison to parameters #1, #2 and #3 the “options” (b, n, l, r, +, -, Z) are not fixed to a parameter position. Anyone of them can be passed/specified in any sequence with every parameter #4 to #8 (or even #2 when no text is passed). There are the following options:
- Option "b"
b
draws a border around the image. This can be useful to show the extensions of the image.
- 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:
{{ F | file name | | size | l }} (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 codel
). E.g.
{{ F | Solid green.svg | r | 16 | T = → → → }} will show rightmost Solid green.svg → → →
- Option "n"
n
: Independent whether the image is displayed or not, the parametern
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 #8. 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/>).
{{ F | file name | any text | size | b | l | n }} is an example for usage of these formatting characters - the sequence does not matter.
- Option "u"
u
: It would have been nice to have also an option "u" – show the file name below of ("under") the displayed picture. But it seems very difficult to do this in all the different conditions, and the gallery function or the template:G is well equipped for that.
- 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.
{{ F | Example.svg | + | 12 }} displays File:Example.svg: 12px, the name space as a part of the link.
- Option "-"
-
: With the minus sign the name space is not a part of the link:
{{ F | Example.svg | l | 12 | - }} displays 12px 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:
{{ F | Example.svg | Test | 12 | + }} will display File:Test: 12px - If as well a
+
and a-
sign are mistakenly defined, the-
is ignored. - Note: Some odd combinations of
+
or-
withn
are currently not working properly, esp. withn
as parameter #3. Use another, better working parameter sequence if so.
- 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; thereforeZ
can be set by either parameter #4 to #8 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 10px16px10px
- Examples
Code | Result | Note |
---|---|---|
{{ F }} | no name | without parameter #1: error display & categorization |
{{ F | Yes_check.svg }} | Yes check.svg | only link |
{{ F | Yes check.svg | | n }} | Yes check.svg | only name - without link |
{{ F | Yes check.svg | | 16 | b }} | Yes check.svg: 16px | bordered |
{{ F | Yes check.svg | | 16 | l }} | 16px Yes check.svg | left of name (as in "other versions" of File:Symbol unrelated.svg.) |
{{ F | Yes check.svg | | 16 | n }} | Yes check.svg: 16px | no link (as in "other versions" of File:Arrow-C.svg.) |
{{ F | Yes check.svg | | 16 | r }} | Yes check.svg: | rightmost display, with file name |
{{ F | Yes check.svg | | 16 | r | Z }} | rightmost 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", "n", "l" or "r" 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", "+", "-", "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 :
(or
with option l).
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.
wikt:
orwiktionary:
n:
orwikinews:
b:
orwikibooks:
q:
orwikiquote:
s:
orwikisource:
Interlanguage links are via ISO 639 codes
- Examples
l=b:es
for an image of the [[|Spanish Wikibooks]]{{F|Pallot1.svg|l=s:it}}
Pallot1.svg for an image of in [[|Italian Wikisource]]
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:
250px Diagram rendered in Arabic |
250px Diagram rendered in Japanese |
250px Diagram rendered in Russian |
Note: The displayed names are linking to the default language version.
Parameter "by" – Author
- Examples
{{ F | Yes check.svg | b | 12 | by = Gmaxwell }} | Yes check.svg: 12px by Gmaxwell |
{{ F | X mark.svg | - | by = {{ut|Anybody||de}} of {{wd}} }} | File:X mark.svg by Anybody of de:Wp |
{{ F | #RR.svg | - | 22 | by = <>nobody }} | File:3RR.svg: 22px by nobody |
{{ F | Yes 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.
Parameter "u" – Author modification code
u=
: 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 u=t
, u=w
, u=wt
.
- Examples
{{ F | Yes check.svg | /Gmaxwell | u = t }} | Yes check.svg by Gmaxwell |
{{ F | Example.svg | by = Example | u = w }} | Example.svg by Example |
Parameter #9 – 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 #3. Such a FFL has precedence, additional parameter settings are ignored.
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 |
---|---|---|---|---|
F | file name | name without extension {{F|F}} | {{F|Flag of….PNG|F}}
|
Flag of Peace (Proposal) |
X | extension | extension without name | {{F|Flag of….PNG|X}} file
|
png file |
{{uc:{{F|Flag of….PNG|X}}}} fileNote: {{uc:}} forcing extension to uppercase.
|
PNG file | |||
U | extension | extension as-it-is, case sensitive | {{F|Flag of….PNG|U}} file
|
PNG file |
I | ifexist | "true" if file exists | {{F|Flag of….PNG|I}}
|
|
C | count | number of file pages | {{F|Flag of….PNG|C}}
|
1 |
D | date | work date, formatted yyyy-mm-dd | {{F|Flag of….PNG|D}}
|
|
W | width | width in pixel | {{F|Flag of….PNG|W}} ×{{F|Flag of….PNG|H}} pixels
|
× pixels |
H | height | height in pixel | ||
V | valid? | {{F|Flag of….PNG|V}} |
||
S | size | file size in bytes | {{F|Flag of….PNG|S}} bytes
|
bytes |
P | page size | size of file description page in bytes | {{F|Flag of….PNG|P}} bytes
|
469 bytes |
G | gallery | gallery style display, see below | {{F|Flag of….PNG|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}}.}}
- 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:
- 32px file name: Buddhist flag (SVG file, nominally × pixels, file size: bytes; description: 641 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:
{{ F | file name | G }} | like <gallery> file name | file name </gallery> | centered |
{{ F | file name | | G }} | like <gallery> file name </gallery> | |
{{ F | file name | caption | G }} | like <gallery> file name | caption </gallery> | centered |
{{ F | file name | G | caption }} | like <gallery> file name | caption </gallery> |
The minus sign can be used to display the name space "File:"
{{ F | file name | G | - }} | like <gallery> file name | File:file name </gallery> | centered |
{{ F | file 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}} | |
---|---|---|
|
| |
|
| |
another example with caption: | ||
|
| |
|
|