Module:Sprite/doc
Appearance
This is the documentation page for Module:Sprite
This is the documentation page for Module:Sprite.
Renders an item icon from the Sanko item sprite atlas as a CSS background-positioned <span>. Atlas coordinates come from the data module Module:Sprite/Item (loaded via mw.loadData).
Functions
item
The only public function. Called as {{#invoke:Sprite|item|name=...|size=...|link=...}}.
| Parameter | Meaning | Default |
|---|---|---|
name (or first positional) |
Item name; must match a key in Module:Sprite/Item's items table exactly (trimmed, case-sensitive). |
— |
size |
Rendered icon size in pixels; the atlas is scaled by size / cell (cell is 32). |
32 |
link |
Page to wikilink the icon to. Empty = no link. | none |
Output is a span.sanko-sprite with role="img", aria-label, and data-minetip-title set to the item name, plus computed background-position/background-size. When link is set the span is wrapped in span.sanko-sprite-link containing a wikilink.
Used by
- Template:ItemSprite —
{{#invoke:Sprite|item|name={{{1|{{{name|}}}}}}|size={{{size|32}}}|link={{{link|}}}}} - Template:Sprite — identical invocation.
Prefer calling these templates from articles rather than #invoke directly, e.g. {{ItemSprite|Air Shard|size=32}}.
Notes and sharp edges
- The lookup is exact-match on the trimmed name. An unknown name does not error; it renders a
span.sanko-sprite-missingplaceholder showing?(minetip "Unknown item" when the name is blank). If an icon shows?, check spelling/capitalization against Module:Sprite/Item. - The module only reads
frame.args, not the parent frame's arguments — templates must passname/size/linkthrough explicitly, as the two templates above do. - The module sets background position/size only; the atlas image itself is attached by the
.sanko-spritesite CSS, not by this module. Theurl/imagefields in the data module are not read here. - Offsets are
math.floor-ed after scaling, so sizes that are not multiples of the 32 px cell can be off by up to a pixel.