Module:CRTGallery: Difference between revisions
Fix delimiter splitting bug — use mw.text.split with plain match instead of gmatch character class (via update-page on MediaWiki MCP Server) |
Rewrite to use mw.smw.getPropertyValues for direct Lua access to semantic properties — avoids frame:preprocess parsing issues (via update-page on MediaWiki MCP Server) |
||
| Line 5: | Line 5: | ||
local mode = args.mode or "packed" | local mode = args.mode or "packed" | ||
local heights = args.heights or "160" | local heights = args.heights or "160" | ||
local pageName = args.page or mw.title.getCurrentTitle().fullText | local pageName = args.page | ||
if not pageName or pageName == "" then | |||
pageName = mw.title.getCurrentTitle().fullText | |||
end | |||
if not | -- Use SMW Lua API to get image values directly | ||
local values = mw.smw.getPropertyValues(pageName, "Has images") | |||
if not values or #values == 0 then | |||
return "" | return "" | ||
end | end | ||
local lines = {} | local lines = {} | ||
for _, | for _, val in ipairs(values) do | ||
local trimmed = mw.text.trim( | local trimmed = mw.text.trim(tostring(val)) | ||
if trimmed ~= "" then | if trimmed ~= "" then | ||
-- Ensure File: prefix | -- Ensure File: prefix | ||