No edit summary
No edit summary
Line 7: Line 7:
     local center_class = false
     local center_class = false
     if args["center"] then
     if args["center"] then
         center_class = true
         if tostring(args["center"]):lower() == "true" then
            center_class = true
        end
         args["center"] = nil
         args["center"] = nil
     end
     end
Line 18: Line 20:
     local outer_div_style = string.format(' style="width:%s;"', width)
     local outer_div_style = string.format(' style="width:%s;"', width)


     local output = ""
     local output = {}
     output = output .. string.format('<div class="%s"%s>\n', classes, outer_div_style)
     table.insert(output, string.format('<div class="%s"%s>', classes, outer_div_style))


     local index = 1
     local images_param = args["images"]
     while true do
     if images_param then
         local paramName
         for filename in string.gmatch(images_param, '([^,]+)') do
        if index == 1 then
             filename = filename:gsub("^%s*(.-)%s*$", "%1") -- trim spaces
             paramName = "image"
             table.insert(output, string.format('[[File:%s.png|%s]]', filename, width))
        else
             paramName = "image" .. index
         end
         end
        local imageName = args[paramName]
        if not imageName then
            break
        end
        output = output .. string.format('[[File:%s|%s]]\n', imageName, width)
        index = index + 1
     end
     end


     output = output .. '</div>'
     table.insert(output, '</div>')


     return output
     return table.concat(output)
end
end


return p
return p

Revision as of 06:01, 27 November 2025

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

local p = {}

function p.render(frame)
    local args = frame:getParent().args
    local width = args["width"] or "200px"

    local center_class = false
    if args["center"] then
        if tostring(args["center"]):lower() == "true" then
            center_class = true
        end
        args["center"] = nil
    end

    local classes = "image-sequence"
    if center_class then
        classes = classes .. " centered"
    end

    local outer_div_style = string.format(' style="width:%s;"', width)

    local output = {}
    table.insert(output, string.format('<div class="%s"%s>', classes, outer_div_style))

    local images_param = args["images"]
    if images_param then
        for filename in string.gmatch(images_param, '([^,]+)') do
            filename = filename:gsub("^%s*(.-)%s*$", "%1") -- trim spaces
            table.insert(output, string.format('[[File:%s.png|%s]]', filename, width))
        end
    end

    table.insert(output, '</div>')

    return table.concat(output)
end

return p