Module:Gallery

Module documentation[view][edit][history][purge]
This documentation is transcluded from Module:Gallery/doc. Changes can be proposed in the talk page.
An icon from the Wikimedia Codex library.
Module:Gallery loads styles from Module:Gallery/styles.css.
Function list
L 5 — p.main
L 10 — p._main

See Template:Gallery for usage instructions.


local getArgs = require('Module:Arguments').getArgs
local p = {}
local root

function p.main(frame)
    local args = getArgs(frame, { parentOnly = true })
    return p._main(args)
end

function p._main(args)
    local filearg = ''
    local height = '150'
    local prependarg = '[[File:'
    local apprendarg = '|frameless|' .. 'x' .. height .. 'px]]'

    for k,_ in pairs(args) do
        local content = args[k]
        -- Check if arg is a valid file name
        if content:match('.[^{}<>]+%.%w+') then
            content = prependarg .. content .. apprendarg
        end
        filearg = filearg .. content
    end

    root = mw.html.create('div')
    root
            :addClass('template-gallery cyac-overflow')
            :wikitext( filearg )

    local frame = mw.getCurrentFrame()

    return frame:extensionTag {
        name = 'templatestyles', args = { src = "Module:Gallery/styles.css" }
    } .. tostring(root)
end

return p