Template:Icon: Difference between revisions

Jump to navigation Jump to search
m (using the newer image missing image)
No edit summary
Line 1: Line 1:
<includeonly>{{#ifexist: File:{{trim | {{{1}}} }} | [[File:{{trim | {{{1}}} }}|link={{{link|}}}|x{{trim | {{{2|40}}} }}px|{{{link|}}}]] | [[File:NoImage Icon.webp|x{{trim | {{{2|40}}} }}px|link={{{link|}}}|{{{link|}}} ''(Icon Missing)'']] }}</includeonly><noinclude>
<includeonly>{{#vardefine:file | {{{1}}} }}[[File:{{#ifexist: File:{{#var:file}} | {{#var:file}} | NoImage Icon.webp }}|link={{{link|}}}|{{#if: {{{w|}}}{{{h|}}} | {{{w|}}}x{{{h|}}}px | x{{trim | {{{2|40}}} }}px }}|{{{link|}}}]]</includeonly><noinclude>
Usage: {{code|<nowiki>{{icon|Flourish Icon.png}}</nowiki>}}
Usage: <pre>{{icon | Flourish Icon.png }}</pre>


Result: {{icon|Flourish Icon.png}}
Result: {{icon | Flourish Icon.png }}


The default size is {{code|x40px}} meaning the icon is scaled until the '''height''' is 40 px.  It's usually important to limit the height since the icons are used inline, and a very high inline image makes for an unpleasant text layout.
The default size is {{code|x40px}} meaning the icon is scaled until the '''height''' is 40 px.  It's usually important to limit the height since the icons are used inline, and a very high inline image makes for an unpleasant text layout.


An alternative value for the height can be provided:
An alternative value for the height can be provided like so:


Usage: {{code|<nowiki>{{icon|Flourish Icon.png|30}}</nowiki>}}
Usage: <pre>{{icon | Flourish Icon.png | 30 }}</pre>


Result: {{icon|Flourish Icon.png|30}}
Result: {{icon | Flourish Icon.png | 30 }}


Usage: {{code|<nowiki>{{icon|Flourish Icon.png|50}}</nowiki>}}
Usage: <pre>{{icon | Flourish Icon.png | 50 }}</pre>


Result: {{icon|Flourish Icon.png|50}}
Result: {{icon | Flourish Icon.png | 50 }}
 
Alternatively you can use the named parameters {{code|w}} and {{code|h}}.  Note that these are max values so the more limiting one applies.  In the following example, the height value is essentially ignored because the original image is a square so the width becomes the limiting factor.  (Were the original image 200 by 500, the result would be 20 by 50.)
 
Usage: <pre>{{icon | Flourish Icon.png | w = 20 | h = 50 }}</pre>
 
Result: {{icon | Flourish Icon.png | w = 20 | h = 50 }}


You can also provide a link:
You can also provide a link:


Usage: {{code|<nowiki>{{icon|Flourish Icon.png|link=Flourish}}</nowiki>}}
Usage: <pre>{{icon | Flourish Icon.png | link = Flourish }}</pre>


Result: {{icon|Flourish Icon.png|link=Flourish}}
Result: {{icon | Flourish Icon.png | link = Flourish }}


Behavior when icon is missing:
Behavior when icon is missing:


Usage: {{code|<nowiki>{{icon|Missing Filename 123.png|link=Flourish}}</nowiki>}}
Usage: <pre>{{icon | Missing Filename 123.png | link = Flourish }}</pre>


Result: {{icon|Missing Filename 123.png|link=Flourish}}
Result: {{icon | Missing Filename 123.png | link = Flourish }}


[[Category:Icon Templates]]
[[Category:Icon Templates]]
</noinclude>
</noinclude>