Template:IconText

From Straftat Wiki

Usage: {{IconText | AK.png | AK }}

Result: {{#lvardef: icon | AK.png }} {{#lvardef: link | }} {{#lvardef: text | AK }} {{#lvardef: min-w | 40 }} {{#lvardef: max-w | }} {{#lvardef: max-h | 40 }}[[File:{{#lvar:icon}}|link={{#lvar:link}}|{{#lvar:max-w}}x{{#lvar:max-h}}px|alt={{#lvar:text}}|class=bg3wiki-icon ]] [[{{#lvar:link}}|{{#lvar:text}}]]

The icon and text can be made into a link:

Usage: {{IconText | AK.png | Custom Text | link = AK }}

Result: {{#lvardef: icon | AK.png }} {{#lvardef: link | AK }} {{#lvardef: text | Custom Text }} {{#lvardef: min-w | 40 }} {{#lvardef: max-w | }} {{#lvardef: max-h | 40 }}[[File:{{#lvar:icon}}|link={{#lvar:link}}|{{#lvar:max-w}}x{{#lvar:max-h}}px|alt={{#lvar:text}}|class=bg3wiki-icon ]] [[{{#lvar:link}}|{{#lvar:text}}]]

The default size is 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 via the size or h parameters, which are synonyms:

Usage: {{IconText | size = 25 | AK.png | AK }}

Result: {{#lvardef: icon | AK.png }} {{#lvardef: link | }} {{#lvardef: text | AK }} {{#lvardef: min-w | 25 }} {{#lvardef: max-w | }} {{#lvardef: max-h | 25 }}[[File:{{#lvar:icon}}|link={{#lvar:link}}|{{#lvar:max-w}}x{{#lvar:max-h}}px|alt={{#lvar:text}}|class=bg3wiki-icon ]] [[{{#lvar:link}}|{{#lvar:text}}]]

Usage: {{IconText | size = 25 | AK.png | Custom Text | link = AK }}

Result: {{#lvardef: icon | AK.png }} {{#lvardef: link | AK }} {{#lvardef: text | Custom Text }} {{#lvardef: min-w | 25 }} {{#lvardef: max-w | }} {{#lvardef: max-h | 25 }}[[File:{{#lvar:icon}}|link={{#lvar:link}}|{{#lvar:max-w}}x{{#lvar:max-h}}px|alt={{#lvar:text}}|class=bg3wiki-icon ]] [[{{#lvar:link}}|{{#lvar:text}}]]

Behavior on missing icon:

{{#lvardef: icon | Missing Icon 123.png }} {{#lvardef: link | }} {{#lvardef: text | AK }} {{#lvardef: min-w | 30 }} {{#lvardef: max-w | }} {{#lvardef: max-h | 30 }}[[File:{{#lvar:icon}}|link={{#lvar:link}}|{{#lvar:max-w}}x{{#lvar:max-h}}px|alt={{#lvar:text}}|class=bg3wiki-icon ]] [[{{#lvar:link}}|{{#lvar:text}}]]

The width can be set via the w parameter. This could be useful if several elements are supposed to align vertically for design purposes, such as in the following table shown on our main page as of the writing of this documentation. This also uses the block and gap parameters. (View the source of this page for usage.)

Setting block to yes ensures that if the text part has to break into multiple lines, the second line doesn't flow under the icon and instead the text is constrained into a rectangular block. The gap parameter can only be provided if block is set to yes, and determines the gap (in px) between the icon and the aforementioned rectangular text block.