Module:Image array and Module:Image array/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
export a Lua-friendly option |
Synced; simplified `tonumber`s by using numbers in the `or`s instead of strings (as it is [presumably] slightly more efficient to do so), and trimmed redundant "or nil" |
||
Line 34: | Line 34: | ||
function p._imagearray( args ) |
function p._imagearray( args ) |
||
local width = tonumber(args['width'] or |
local width = tonumber(args['width'] or 60) |
||
local height = tonumber(args['height'] or |
local height = tonumber(args['height'] or 70) |
||
local perrow = tonumber(args['perrow'] or |
local perrow = tonumber(args['perrow'] or 4) |
||
local bw = tonumber(args['border-width'] or |
local bw = tonumber(args['border-width'] or 0) |
||
local fs = args['font-size'] or '88%' |
local fs = args['font-size'] or '88%' |
||
local text = args['text'] or '' |
local text = args['text'] or '' |
||
local margin = args['margin'] or 'auto' |
local margin = args['margin'] or 'auto' |
||
local border = ( bw > 0 ) and tostring(bw) .. 'px #aaa solid' |
local border = ( bw > 0 ) and tostring(bw) .. 'px #aaa solid' |
||
-- find all the nonempty image numbers |
-- find all the nonempty image numbers |
||
Line 47: | Line 47: | ||
local imagecount = 0 |
local imagecount = 0 |
||
for k, v in pairs( args ) do |
for k, v in pairs( args ) do |
||
local i = tonumber(tostring(k):match( '^%s*image([%d]+)%s*$' ) or |
local i = tonumber(tostring(k):match( '^%s*image([%d]+)%s*$' ) or 0) |
||
if( i > 0 and isnotempty(v) ) then |
if( i > 0 and isnotempty(v) ) then |
||
table.insert( imagenums, i ) |
table.insert( imagenums, i ) |