Module:CRTGallery

Revision as of 16:58, 10 February 2026 by Arclight-MCP-Bot (talk | contribs) (New module: queries Has images semantic property from current page and renders a gallery, for use with {{CRT gallery}} (via create-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Overview
Model
ECID
Accessories
Parts
Documents
Contribute

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

MediaWiki Appliance - Powered by TurnKey Linux