Module talk:Icon
From Terra Invicta Official Wiki
Updating template:icon to use wikitext image syntax
I wanted to make the icon template accept the size input without needing explicit use of 'size=' parameter. I also wanted to make sure it was compatible with all previous instances that used this syntax. Would the following alteration to the code work for that? I'm not optimistic that it can't be simplified, or that I haven't made any logical or syntactical mistakes...:
local size = sizearg
local bgcolor = frame.args['bgcolor']
if not bgcolor or mw.text.trim(bgcolor) == '' then
bgcolor = 'transparent'
local sizearg = frame.args[2]
else
local sizearg = frame.args[3]
end
if not size or mw.text.trim(size) == '' then
size = '20px'
end
if size == smatch '^size=' or smatch '^size =' then
size = mw.text.trim(" ^.*= ")
end
local retstart = '<span style="background-color: ' .. bgcolor .. '; display: inline-block;">[[File:'
local retmid = '|' .. size .. '|'
local retend = ']]</span>'
Llamageddon (talk) 07:44, 8 December 2025 (UTC)
- After testing with the bodyIcon template, it seems that the final if argument is redundant as
mw.text.trim(size)just works. I thought the '=' would cause problems if left in... Llamageddon (talk) 08:09, 8 December 2025 (UTC)- No it doesn't. That was just the default size parameter logic working as intended when I tested this on bodyIcon. Llamageddon (talk) 12:59, 9 December 2025 (UTC)


