Module:ProjectGallery: Difference between revisions

From Makerpedia

EvaC (talk | contribs)
Blanked the page
EvaC (talk | contribs)
No edit summary
 
Line 1: Line 1:
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:%25s|link=%s|alt=%s|thumb|200x200px|<center>[[%s]]</center>]]
',
                img, title, title, title
            ))
        end
    end
return '<gallery>
File:\n'_.._table.concat(gallery,_"\n")_.._'\n
</gallery>'
end
return p

Latest revision as of 18:15, 8 February 2025

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(

'

%s
%s

',

               img, title, title, title
           ))
       end
   end

return '

'

end

return p