Module:EveryCRTImages: Difference between revisions

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)
Update comments to reference {{EveryCRT gallery}} instead of {{CRT gallery}}/{{CRT model}}; change fallback default mode to nolines (via update-page on MediaWiki MCP Server)
 
Line 42: Line 42:
-- Extract the |images= value from the current page's wikitext.
-- Extract the |images= value from the current page's wikitext.
-- Reads the raw source via mw.title:getContent() and parses out
-- Reads the raw source via mw.title:getContent() and parses out
-- the images parameter from the {{CRT model}} template invocation.
-- the images parameter from the page's content template invocation
-- (works with {{CRT model}}, {{AV device}}, or any template with an images= field).
local function getImagesFromPageSource()
local function getImagesFromPageSource()
   local title = mw.title.getCurrentTitle()
   local title = mw.title.getCurrentTitle()
Line 58: Line 59:


-- Auto-gallery: reads the current page's wikitext to find the images= field
-- Auto-gallery: reads the current page's wikitext to find the images= field
-- from {{CRT model}}, then renders a gallery. No parameters required.
-- from the page's content template, then renders a gallery. No parameters required.
-- Called by {{CRT gallery}}.
-- Called by {{EveryCRT gallery}}.
function p.autoGallery(frame)
function p.autoGallery(frame)
   -- Allow explicit override via images= parameter
   -- Allow explicit override via images= parameter
Line 71: Line 72:
   if imageList == "" then return "" end
   if imageList == "" then return "" end


   local mode = getArg(frame, "mode", "packed")
   local mode = getArg(frame, "mode", "nolines")
   local heights = getArg(frame, "heights", "160")
   local heights = getArg(frame, "heights", "160")


Line 94: Line 95:
-- Emits SMW annotations for a multi-image list:
-- Emits SMW annotations for a multi-image list:
-- [[Has images::File:...]] repeated
-- [[Has images::File:...]] repeated
-- Called by {{CRT model}} and {{AV device}}.
function p.annotate(frame)
function p.annotate(frame)
   local args = frame:getParent().args
   local args = frame:getParent().args
Line 110: Line 112:
end
end


-- Renders a gallery from the list (optional)
-- Renders a gallery from a comma-separated image list.
-- Called by {{CRT model}} and {{AV device}} for their default inline gallery.
function p.gallery(frame)
function p.gallery(frame)
   local args = frame:getParent().args
   local args = frame:getParent().args
   local list = args.images or ""
   local list = args.images or ""
   local mode = args.mode or "packed"
   local mode = args.mode or "nolines"
   local heights = args.heights or "160"
   local heights = args.heights or "160"


MediaWiki Appliance - Powered by TurnKey Linux