More actions
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local images = args['images'] or '' | local images = args['images'] or '' | ||
local texts = args['texts'] or '' | local texts = args['texts'] or '' | ||
local links = args['links'] or '' | local links = args['links'] or '' | ||
local imageList = mw.text.split(images, ',') | local imageList = mw.text.split(images, ',') | ||
local textList = mw.text.split(texts, ',') | local textList = mw.text.split(texts, ',') | ||
local linkList = mw.text.split(links, ',') | local linkList = mw.text.split(links, ',') | ||
local | -- holds everything basically | ||
local output = "" | |||
for i = 1, math.max(#imageList, #textList, #linkList) do | for i = 1, math.max(#imageList, #textList, #linkList) do | ||
local image = mw.text.trim(imageList[i] or 'Noimg.png') | local image = mw.text.trim(imageList[i] or 'Noimg.png') | ||
local text = mw.text.trim(textList[i] or '') | local text = mw.text.trim(textList[i] or '') | ||
local link = mw.text.trim(linkList[i] or '') | local link = mw.text.trim(linkList[i] or '') | ||
output = output .. '<div class="image-wrapper">' | |||
if link ~= '' then | if link ~= '' then | ||
output = output .. string.format('[[%s|[[File:%s|200px]]]]', link, image) | |||
if text ~= '' then | if text ~= '' then | ||
output = output .. string.format('[[%s|<div class="image-text">%s</div>]]', link, text) | |||
end | end | ||
else | else | ||
output = output .. string.format('[[File:%s|200px]]', image) | |||
if text ~= '' then | if text ~= '' then | ||
output = output .. string.format('<div class="image-text">%s</div>', text) | |||
end | end | ||
end | end | ||
output = output .. '</div>' | |||
end | end | ||
return | return output | ||
end | end | ||
return p | return p |
Revision as of 02:45, 17 September 2024
Documentation for this module may be created at Module:ImageGrid/doc
local p = {}
function p.renderImageGrid(frame)
local args = frame:getParent().args
local images = args['images'] or ''
local texts = args['texts'] or ''
local links = args['links'] or ''
local imageList = mw.text.split(images, ',')
local textList = mw.text.split(texts, ',')
local linkList = mw.text.split(links, ',')
-- holds everything basically
local output = ""
for i = 1, math.max(#imageList, #textList, #linkList) do
local image = mw.text.trim(imageList[i] or 'Noimg.png')
local text = mw.text.trim(textList[i] or '')
local link = mw.text.trim(linkList[i] or '')
output = output .. '<div class="image-wrapper">'
if link ~= '' then
output = output .. string.format('[[%s|[[File:%s|200px]]]]', link, image)
if text ~= '' then
output = output .. string.format('[[%s|<div class="image-text">%s</div>]]', link, text)
end
else
output = output .. string.format('[[File:%s|200px]]', image)
if text ~= '' then
output = output .. string.format('<div class="image-text">%s</div>', text)
end
end
output = output .. '</div>'
end
return output
end
return p