No edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 3: Line 3:
function p.render(frame)
function p.render(frame)
     local args = frame:getParent().args
     local args = frame:getParent().args
     local size = args["size"] -- optional size
     local width = args["width"] or "200px"
    local output = ""


     -- Start the div with hardcoded class
     local center_class = false
     output = output .. '<div class="image-sequence"><div class="image-sequence-row">'
     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 index = 1
     local output = {}
    while true do
        local paramName
        if index == 1 then
            paramName = "image"
        else
            paramName = "image" .. index
        end


        local imageName = args[paramName]
    table.insert(output, string.format('<div class="%s"%s>', classes, outer_div_style))
        if not imageName then
    table.insert(output, '<div class="image-sequence-group">')
            break -- no more images
        end


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


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


     return output
     return table.concat(output)
end
end


return p
return p

Latest revision as of 06:10, 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))
    table.insert(output, '<div class="image-sequence-group">')

    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></div>')

    return table.concat(output)
end

return p