Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:ImageGrid

From MassiveCraft Wiki
Revision as of 02:29, 17 September 2024 by OkaDoka (talk | contribs) (Created page with "local p = {} function p.renderImageGrid(frame) local args = frame:getParent().args local images = mw.text.split(args['images'], ',') local texts = mw.text.split(args['texts'], ',') local imageCount = #images local html = mw.html.create('div'):addClass('image-grid-container') for i = 1, imageCount do local imageWrapper = html:tag('div'):addClass('image-wrapper') local imageTag = imageWrapper:tag('img') :attr('src', ima...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:ImageGrid/doc

local p = {}

function p.renderImageGrid(frame)
    local args = frame:getParent().args
    local images = mw.text.split(args['images'], ',')
    local texts = mw.text.split(args['texts'], ',')
    local imageCount = #images
    local html = mw.html.create('div'):addClass('image-grid-container')

    for i = 1, imageCount do
        local imageWrapper = html:tag('div'):addClass('image-wrapper')
        local imageTag = imageWrapper:tag('img')
            :attr('src', images[i])
            :attr('alt', texts[i] or '')
        local textTag = imageWrapper:tag('div'):addClass('image-text'):wikitext(texts[i] or '')
    end

    return tostring(html)
end

return p