Шаблон:Ifimage — различия между версиями
Материал из Guild Wars 2 wiki
Blood (обсуждение | вклад) (Новая страница: «<includeonly>{{#if: {{filepath:{{#replace:{{{1|}}}|File:|}}}} | {{{2|}}} | {{{3|}}} }}</includeonly><noinclude> == Description == <pre> {{ifimage|(filename)|(then…») |
Blood (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
− | <includeonly>{{#if: {{filepath:{{#replace:{{{1|}}}|File:|}}}} | {{{2|}}} | {{{3|}}} }}</includeonly><noinclude> | + | <includeonly>{{#if: {{filepath:{{#titleparts:{{#replace:{{{1|}}}|File:|}}}}}} | {{{2|}}} | {{{3|}}} }}</includeonly><noinclude> |
== Description == | == Description == | ||
+ | This template is similar to [[mw:Help:Extension:ParserFunctions##ifexist|<nowiki>{{#ifexist:}}</nowiki>]] + {{tl|Ifexists}} as it checks the existence of the given file - this template however only works for files - not pages. The difference is that the checked file is not added to [[Special:Wantedpages|Wanted pages]], and no hefty DPL is needed either. Instead, it uses the MediaWiki built-in function [[mw:Help:Magic words#URL data|<nowiki>{{filepath:}}</nowiki>]]. | ||
+ | |||
+ | == Usage == | ||
<pre> | <pre> | ||
{{ifimage|(filename)|(then)|(else)}} | {{ifimage|(filename)|(then)|(else)}} | ||
</pre> | </pre> | ||
− | |||
− | |||
=== Parameters === | === Parameters === | ||
− | ; ''unnamed parameter'' | + | ;1 ''(unnamed parameter)'' |
: File name without braces, including namespace. | : File name without braces, including namespace. | ||
− | ; ''unnamed parameter'' | + | ;2 ''(unnamed parameter)'' |
: Optional. Wikitext if page exists. | : Optional. Wikitext if page exists. | ||
− | ; ''unnamed parameter'' | + | ;3 ''(unnamed parameter)'' |
− | : Optional. Wikitext if page does not | + | : Optional. Wikitext if page does not exist. |
== Example == | == Example == |
Текущая версия на 13:11, 18 мая 2022
Содержание
Description[править]
This template is similar to {{#ifexist:}} + {{Ifexists}} as it checks the existence of the given file - this template however only works for files - not pages. The difference is that the checked file is not added to Wanted pages, and no hefty DPL is needed either. Instead, it uses the MediaWiki built-in function {{filepath:}}.
Usage[править]
{{ifimage|(filename)|(then)|(else)}}
Parameters[править]
- 1 (unnamed parameter)
- File name without braces, including namespace.
- 2 (unnamed parameter)
- Optional. Wikitext if page exists.
- 3 (unnamed parameter)
- Optional. Wikitext if page does not exist.
Example[править]
[[File:{{ifimage|Frenzy (black and white).png|Frenzy (black and white).png|Skill.png}}|20px]]