Module:Gallery items explained

-- this module implements local p =

function p.main(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame)

local width = args.width or '150'

local items = local itemnums = for k, v in pairs(args) do if k ~= nil and tonumber(k) and math.fmod(k,2)

1 then local i = math.floor(k/2) + 1 table.insert(itemnums, i) local item = mw.html.create('li') :addClass('gallerybox') :css('width', (args['width' .. k] or width)+5 .. 'px') local itemdiv = item:tag('div'):css('width', (args['width' .. k] or width)+5 .. 'px') itemdiv:tag('div') :addClass('thumb') :css('width', (args['width' .. k] or width) .. 'px') :css('text-align', args['itemalign']) :wikitext('

' .. args[k] .. '

') if args[tonumber(k)+1] then itemdiv :tag('div') :addClass('gallerytext') :css('text-align', args['captionalign']) :wikitext('

' .. args[tonumber(k)+1] .. '

') end items[i] = tostring(item) .. ' ' end end -- remove blanks table.sort(itemnums) local sorteditems = for k = 1, #itemnums do sorteditems[k] = items[itemnums[k]] end

local root = mw.html.create('ul') :addClass('gallery mw-gallery-nolines gallery-items') :addClass(args.class) :cssText(args.style) :wikitext(table.concat(sorteditems)) return frame:extensionTag .. frame:extensionTag .. tostring(root)end

return p