Difference between revisions of "Module:InfoboxImage"

From Encyclopedia Westarctica
Jump to navigation Jump to search
(Infobox image)
 
 
Line 18: Line 18:
local link = clean(args.link)
local link = clean(args.link)


local options = {
local result
alt = alt,
title = title,
link = link,
class = 'infobox-image',
}


local imageTag = mw.getCurrentFrame():extensionTag('image', '', {
if link then
src = image,
result = string.format('[[File:%s|%s|alt=%s|link=%s', image, size, alt, link)
width = size,
else
alt = alt,
result = string.format('[[File:%s|%s|alt=%s', image, size, alt)
title = title
end
})


-- Fallback if extensionTag fails (older wikis)
if title then
if not imageTag or imageTag == '' then
result = result .. '|' .. title
local out = '[[File:' .. image .. '|' .. size
if alt ~= '' then out = out .. '|alt=' .. alt end
if title then out = out .. '|' .. title end
out = out .. ']]'
return out
end
end


return imageTag
result = result .. ']]'
 
return result
end
end


return p
return p

Latest revision as of 15:59, 27 July 2025

local p = {}

local function clean(s) if type(s) ~= 'string' then return nil end s = mw.text.trim(s) if s == or s:lower() == 'none' then return nil end return s end

function p.InfoboxImage(frame) local args = frame:getParent().args local image = clean(args.image) or 'No image.svg' local size = clean(args.size) or '220px' local alt = clean(args.alt) or local title = clean(args.title) local link = clean(args.link)

local result

if link then result = string.format('[[File:%s|%s|alt=%s|link=%s', image, size, alt, link) else result = string.format('' .. title end result = result .. ''

return result end

return p