local p = {}
function p.gallery(frame)
local args = frame:getParent().args local mode = args.mode or "packed" local heights = args.heights or "160" local pageName = args.page or mw.title.getCurrentTitle().fullText
-- Query all "Has images" values stored by
on this page
local query = string.format(
,
pageName
)
local result = frame:preprocess(query)
if not result or result == "" then
return ""
end
-- Split on delimiter; each value is a File: title
local lines = {}
for part in result:gmatch("([^<DELIM>]+)") do
local trimmed = mw.text.trim(part)
if trimmed ~= "" then
-- Ensure File: prefix
if not trimmed:match("^[Ff]ile:") then
trimmed = "File:" .. trimmed
end
table.insert(lines, trimmed)
end
end
if #lines == 0 then return "" end
local wikitext = string.format(
'
',
mode, heights, table.concat(lines, "\n") )
return frame:preprocess(wikitext)
end
return p