Module:ProjectGallery

From Makerpedia

Revision as of 18:11, 8 February 2025 by EvaC (talk | contribs) (Created page with "local p = {} function p.generateGallery(frame) local category = "Projects" local pages = mw.site.categoryMembers(category, "all") -- Get all project pages local gallery = {} for _, page in ipairs(pages) do local title = page.title local content = mw.title.new(title):getContent() local img = content and content:match("img1=(https://[^\n|}%s]+)") or nil if img then table.insert(gallery, string.format(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.generateGallery(frame)

   local category = "Projects"
   local pages = mw.site.categoryMembers(category, "all") -- Get all project pages
   local gallery = {}
   for _, page in ipairs(pages) do
       local title = page.title
       local content = mw.title.new(title):getContent()
       local img = content and content:match("img1=(https://[^\n|}%s]+)") or nil
       if img then
           table.insert(gallery, string.format(

'File:%s|link=%s|alt=%s|thumb|200px|

%s

',

               img, title, title, title
           ))
       end
   end

return '

'

end

return p