Module:EveryCRTImages: Difference between revisions
Fix: read images from frame.args (direct #invoke params) not frame:getParent().args; same for recallGallery mode/heights (via update-page on MediaWiki MCP Server) |
Replace storeImages/recallGallery with autoGallery — reads current page wikitext via mw.title:getContent() to extract images= field, no cross-template state needed (via update-page on MediaWiki MCP Server) |
||
| Line 40: | Line 40: | ||
end | end | ||
-- | -- Extract the |images= value from the current page's wikitext. | ||
local | -- Reads the raw source via mw.title:getContent() and parses out | ||
-- the images parameter from the {{CRT model}} template invocation. | |||
local function getImagesFromPageSource() | |||
local title = mw.title.getCurrentTitle() | |||
local content = title:getContent() | |||
if not content then return nil end | |||
-- | -- Match |images= value: capture everything after |images= up to the next | ||
-- | -- pipe-prefixed parameter (|paramname=) or closing braces (}}) | ||
local images = content:match("|images%s*=%s*([^|}]+)") | |||
if images then | |||
return trim(images) | |||
return | end | ||
return nil | |||
end | end | ||
-- | -- Auto-gallery: reads the current page's wikitext to find the images= field | ||
-- from {{CRT model}}, then renders a gallery. No parameters required. | |||
-- Called by {{CRT gallery}}. | -- Called by {{CRT gallery}}. | ||
function p. | function p.autoGallery(frame) | ||
if | -- Allow explicit override via images= parameter | ||
local imageList = getArg(frame, "images", "") | |||
-- If no explicit images, read from page source | |||
if imageList == "" then | |||
imageList = getImagesFromPageSource() or "" | |||
end | end | ||
if imageList == "" then return "" end | |||
local mode = getArg(frame, "mode", "packed") | local mode = getArg(frame, "mode", "packed") | ||
| Line 62: | Line 75: | ||
local lines = {} | local lines = {} | ||
for _, raw in ipairs(split_csv( | for _, raw in ipairs(split_csv(imageList)) do | ||
local title = normalize_file_title(raw) | local title = normalize_file_title(raw) | ||
if title then | if title then | ||