Module:Gallery
Jump to navigation
Jump to search
This module implements {{Gallery}}
.
local p = {}
function p.create(f)
local args, filename, filetype, output = f:getParent().args, "", "", {}
for k, v in pairs(args) do
if type(k) == "number" and (not args.dynamic or k % 2 == 1) then
filename, filetype = mw.text.trim(v), mw.text.trim(tostring(args[k + 1] or ""))
output[k] = (args.prefix or "") .. (args.portrait and (not args.dynamic or filetype ~= "gif") and "Portrait " or "") .. filename .. "." .. (args.dynamic and filetype or args.gif and "gif" or "png") .. "|link=" .. (args.noimagelink and "" or filename).. "|" .. (args.notext and "" or (args.nocount and "" or (args.dynamic and (k + 1) / 2 or k) .. ". ") .. (args.noimagelink and filename or "[[" .. filename .. "]]"))
else
output[k] = ""
end
end
return f:extensionTag("gallery", table.concat(output, "\n"), {class="pixel-image"})
end
return p