Module:Icon
Appearance
Uses Lua: |
This template creates an inline image that is used in metapages such as Wikipedia:Vital articles and/or in user pages.
Syntax
Basic usage
{{icon|code}}
{{icon|class=code}}
Custom size
{{icon|code|size=size}}
Parameters
1
orclass
- the icon code. See the table below for a list of available codes.size
- a custom icon size, e.g. "30px". The default size is "16x16px" (16 by 16 pixels).
Icon codes
|
|
TemplateData
This template creates an inline icon-sized image. Please refer to 'Template:Icon/doc' for the list of supported values.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Icon | 1 class | The identifier or name of the icon to be displayed.
| Line | optional |
size | size | The size of the icon to display, e.g. "30px".
| Line | optional |
See also
- {{icon+link}}
-- This module implements [[Template:Icon]].
local data = mw.loadData('Module:Icon/data')
local p = {}
function p._main(args)
local code = args.class or args[1]
local iconData
if code then
code = code:match('^%s*(.-)%s*$'):lower() -- trim whitespace and put in lower case
iconData = data[code]
end
if not iconData then
iconData = data._DEFAULT
end
return string.format(
'[[File:%s%s|%s|link=]]',
iconData.image,
iconData.tooltip and '|' .. iconData.tooltip or '',
args.size or '16x16px'
)
end
function p.main(frame)
local args = {}
for k, v in pairs(frame:getParent().args) do
args[k] = v
end
return p._main(args)
end
return p