Module:Expanded infobox image

From Geometry Dash Expanded Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Expanded infobox image/doc

local p = {}
function p.render(frame)
    local value = mw.text.trim(frame.args[1] or '')
    if value == '' then return '' end
    -- Gallery tags arrive as parser strip markers. Preserve those and supplied markup.
    if value:find(string.char(127), 1, true) or value:find('[[', 1, true) or value:find('<', 1, true) then
        return value
    end
    value = value:gsub('^[Ff][Ii][Ll][Ee]:', ''):gsub('^[Ii][Mm][Aa][Gg][Ee]:', '')
    if mw.text.trim(value) == '' then return '' end
    local width = tonumber(frame.args.width) or 300
    if width < 1 or width > 2000 then width = 300 end
    return '[[File:' .. value .. '|' .. math.floor(width) .. 'px]]'
end
return p