Template:Item icon: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
(Add rarity support)
(Overhaul examples)
Line 1: Line 1:
<includeonly><onlyinclude>{{#cargo_query:
<includeonly><onlyinclude>{{#lvardef:margin|{{#expr:0.01 * {{{size|40}}} }} }}<span class="bg3wiki-itemicon-wrapper" style="margin: auto {{#lvar:margin}}rem">{{#cargo_query:
tables=item_icon
tables=item_icon
|fields=TRIM(icon),CONCAT('', '{{{size|40}}}'),rarity,CONCAT('', '{{{show_rarity|}}}')
|fields=TRIM(icon),CONCAT('', '{{{size|40}}}'),rarity,CONCAT('', '{{{show_rarity|}}}')
Line 9: Line 9:
|format=template
|format=template
|template=ItemIcon Internal
|template=ItemIcon Internal
}} {{#if:{{{show_name|}}}|[[{{{name}}}]] }}</onlyinclude></includeonly><noinclude>
}} <span class="bg3wiki-itemicon-link" style="margin-left: {{#lvar:margin}}rem;">{{#if:{{{show_name|}}}|[[{{{name}}}]] }}</span></span></onlyinclude></includeonly><noinclude>


This template fetches and displays an icon for an item. The information is uploaded using the standard item descriptions. Use [[Template:ItemIcon Insert]] to add a page that doesn't use [[Template:MiscItemPage]], [[Template:EquipmentPage]], or [[Template:WeaponPage]].
This template fetches and displays an icon for an item. The information is uploaded using the standard item descriptions. Use [[Template:ItemIcon Insert]] to add a page that doesn't use [[Template:MiscItemPage]], [[Template:EquipmentPage]], or [[Template:WeaponPage]].
Line 28: Line 28:
Copy-ready template (with item name): <code><nowiki>{{ItemIcon|name=|show_name=true}}</nowiki></code>
Copy-ready template (with item name): <code><nowiki>{{ItemIcon|name=|show_name=true}}</nowiki></code>


== Examples ==
=== Examples ===
<code><nowiki>{{ItemIcon|name=Potion of Healing}}</nowiki></code> {{ItemIcon|name=Potion of Healing}}
<table class="wikitable">
<tr><th>Result</th><th>Name</th><th>Size</th><th>Show name?</th><th>Rarity?</th><th>Code</th></tr>
<!-- just the icon -->
{{/Example|Potion of Healing|40|false|false}}
{{/Example|Potion of Healing|25|false|false}}
{{/Example|Potion of Supreme Healing|40|false|false}}
{{/Example|Potion of Supreme Healing|25|false|false}}
{{/Example|The Red Knight's Final Stratagem|40|false|false}}
{{/Example|The Red Knight's Final Stratagem|25|false|false}}
<!-- icon and link -->
{{/Example|Potion of Healing|40|true|false}}
{{/Example|Potion of Healing|25|true|false}}
{{/Example|Potion of Supreme Healing|40|true|false}}
{{/Example|Potion of Supreme Healing|25|true|false}}
{{/Example|The Red Knight's Final Stratagem|40|true|false}}
{{/Example|The Red Knight's Final Stratagem|25|true|false}}


<code><nowiki>{{ItemIcon|name=Potion of Healing|size=30}}</nowiki></code> {{ItemIcon|name=Potion of Healing|size=30}}
<!-- rarity and link -->
 
{{/Example|Potion of Healing|40|true|true}}
<code><nowiki>{{ItemIcon|name=Potion of Healing|size=24|show_name=true}}</nowiki></code> {{ItemIcon|name=Potion of Healing|size=24|show_name=true}}
{{/Example|Potion of Healing|25|true|true}}
 
{{/Example|Potion of Supreme Healing|40|true|true}}
<code><nowiki>{{ItemIcon|name=The Red Knight's Final Stratagem}} (testing that pages with ' work)</nowiki></code> {{ItemIcon|name=The Red Knight's Final Stratagem}}
{{/Example|Potion of Supreme Healing|25|true|true}}
{{/Example|The Red Knight's Final Stratagem|40|true|true}}
{{/Example|The Red Knight's Final Stratagem|25|true|true}}
</table>


<!-- Cargo table definition -->
<!-- Cargo table definition -->

Revision as of 09:35, 9 September 2023


This template fetches and displays an icon for an item. The information is uploaded using the standard item descriptions. Use Template:ItemIcon Insert to add a page that doesn't use Template:MiscItemPage, Template:EquipmentPage, or Template:WeaponPage.

See /Family for information on the various ItemIcon templates.

Usage:
{{ItemIcon
|name=the name of the icon page
|size=(optional) the size of the icon
|show_name=(optional) Whether to show the name. Any value will show the name of the item as a link. Omit to hide it.
|show_rarity=(optional) Whether to add a border and background to the icon according to the item's rarity. Omit to not show it.
}}

Templates

Copy-ready template (no item name): {{ItemIcon|name=}}

Copy-ready template (with item name): {{ItemIcon|name=|show_name=true}}

Examples

ResultNameSizeShow name?Rarity?Code

Potion of Healing

40 false false {{ItemIcon|name=Potion of Healing|size=40|show_name=false|show_rarity=false}}

Potion of Healing

25 false false {{ItemIcon|name=Potion of Healing|size=25|show_name=false|show_rarity=false}}

Potion of Supreme Healing

40 false false {{ItemIcon|name=Potion of Supreme Healing|size=40|show_name=false|show_rarity=false}}

Potion of Supreme Healing

25 false false {{ItemIcon|name=Potion of Supreme Healing|size=25|show_name=false|show_rarity=false}}

The Red Knight's Final Stratagem

40 false false {{ItemIcon|name=The Red Knight's Final Stratagem|size=40|show_name=false|show_rarity=false}}

The Red Knight's Final Stratagem

25 false false {{ItemIcon|name=The Red Knight's Final Stratagem|size=25|show_name=false|show_rarity=false}}

Potion of Healing

40 true false {{ItemIcon|name=Potion of Healing|size=40|show_name=true|show_rarity=false}}

Potion of Healing

25 true false {{ItemIcon|name=Potion of Healing|size=25|show_name=true|show_rarity=false}}

Potion of Supreme Healing

40 true false {{ItemIcon|name=Potion of Supreme Healing|size=40|show_name=true|show_rarity=false}}

Potion of Supreme Healing

25 true false {{ItemIcon|name=Potion of Supreme Healing|size=25|show_name=true|show_rarity=false}}

The Red Knight's Final Stratagem

40 true false {{ItemIcon|name=The Red Knight's Final Stratagem|size=40|show_name=true|show_rarity=false}}

The Red Knight's Final Stratagem

25 true false {{ItemIcon|name=The Red Knight's Final Stratagem|size=25|show_name=true|show_rarity=false}}

Potion of Healing

40 true true {{ItemIcon|name=Potion of Healing|size=40|show_name=true|show_rarity=true}}

Potion of Healing

25 true true {{ItemIcon|name=Potion of Healing|size=25|show_name=true|show_rarity=true}}

Potion of Supreme Healing

40 true true {{ItemIcon|name=Potion of Supreme Healing|size=40|show_name=true|show_rarity=true}}

Potion of Supreme Healing

25 true true {{ItemIcon|name=Potion of Supreme Healing|size=25|show_name=true|show_rarity=true}}

The Red Knight's Final Stratagem

40 true true {{ItemIcon|name=The Red Knight's Final Stratagem|size=40|show_name=true|show_rarity=true}}

The Red Knight's Final Stratagem

25 true true {{ItemIcon|name=The Red Knight's Final Stratagem|size=25|show_name=true|show_rarity=true}}

This template defines the table "item_icon". View table.

Template Data Section

Inserts an item's icon automatically. Can also display a link to the item.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
namename

The name of the icon. Identical to the item's page name.

Example
Potion of Healing
Page namerequired
sizesize

The height of the item icon. Optional.

Suggested values
40 25 20
Default
40
Numberoptional
show_nameshow_name

Whether to link the icon as well. Optional. Providing any value at all will be interpreted as "yes".

Booleanoptional