Module:ProjectGallery: Difference between revisions

From Makerpedia

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(..."
 
EvaC (talk | contribs)
Blanked the page
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:%s|link=%s|alt=%s|thumb|200px|<center>[[%s]]</center>',
                img, title, title, title
            ))
        end
    end
    return '<gallery>\n' .. table.concat(gallery, "\n") .. '\n</gallery>'
end
return p

Revision as of 18:14, 8 February 2025