Module:Tile

From Predecessor Wiki
Jump to navigation Jump to search
Template-noinfo.svg Documentation
This module has no documentation. If you know how to use this module, please add some. Module:Tile/doc

local p = {}

function p.main(frame)
    local args = frame:getParent().args

    local css = args.css or ''
    local float = args.float or ''
    local width = args.width or args.w or args[4] or '100'
    local height = args.height or args.h or args[5] or '100'
    local image = args.image or args[1] or ''
    local link = args.link or args[3] or ''
    local crop = args.crop or ''
    local caption = args.caption or args[2] or ''

    local style = 'class="tile" style="'
    if css ~= '' then style = style .. css end
    if float ~= '' then style = style .. ' float: ' .. float .. ';' end
    local style = style .. '"'
    
    local imgClass = 'tile-image'
    if crop ~= '' then imgClass = imgClass .. ' img-' .. crop end

    local output = '{| ' .. style .. '\n'
    output = output .. '|style="width:' .. width .. 'px; height:' .. height .. 'px;"|[[Image:' .. image .. '|300px'
    
    if link ~= '' then output = output .. '|' .. 'link=' .. link end
    
    output = output .. '|' .. 'class=' .. imgClass .. ']]\n'
    
    if caption ~= '' then
        output = output .. '|-\n|'
        if link ~= '' then output = output .. '[[' .. link .. '|' .. caption .. ']]\n'
        else output = output .. caption .. '\n' end
    end
    output = output .. '|}'

    return output
end

return p