Module:Multiple image: Difference between revisions

m
1 revision imported from wikipedia:Module:Multiple_image
m (1 revision imported)
m (1 revision imported from wikipedia:Module:Multiple_image)
 
(3 intermediate revisions by 3 users not shown)
Line 7:
local function isnotempty(s)
return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end
 
local function removepx(s)
return tostring(s or ''):match('^(.*)[Pp][Xx]%s*$') or s
end
 
Line 22 ⟶ 26:
end
 
local function renderImageCell(image, width, height, link, alt, thumbtime, caption, textalign, istyle, border)
local root = mw.html.create('')
 
Line 30 ⟶ 34:
local thumbtimestr = ''
 
if widthstr == '|-nanpx' then
widthstr = ''
end
if isnotempty( thumbtime ) then
thumbtimestr = '|thumbtime=' .. thumbtime
Line 35 ⟶ 42:
 
local imagediv = root:tag('div')
imagediv:addClass((border ~= 'infobox') and 'thumbimage' or nil)
imagediv:cssText(istyle)
if( height ) then
Line 44 ⟶ 51:
if isnotempty(caption) then
local captiondiv = root:tag('div')
captiondiv:addClass((border ~= 'infobox') and 'thumbcaption' or nil)
if isnotempty(textalign) then
captiondiv:addClass('text-align-' .. textalign)
Line 89 ⟶ 96:
local pargs = frame:getParent().args
local args = frame.args
local width = removepx(pargs['width'] or '')
local dir = pargs['direction'] or ''
local border = pargs['border'] or args['border'] or ''
local align = pargs['align'] or args['align'] or (border == 'infobox' and 'center' or '')
local capalign = pargs['caption_align'] or args['caption_align'] or ''
local totalwidth = removepx(pargs['total_width'] or args['total_width'] or '')
local imgstyle = pargs['image_style'] or args['image_style']
local header = pargs['header'] or pargs['title'] or ''
Line 225 ⟶ 232:
 
local div = root:tag('div')
div:addClass((border ~= 'infobox') and 'thumbinner multiimageinner' or 'multiimageinner')
div:css('width', tostring(bodywidth) .. 'px')
:css('max-width', tostring(bodywidth) .. 'px')
Line 240 ⟶ 247:
:tag('div')
:addClass('theader')
:css('text-align', pargs['header_align'] or 'center')
:css('background-color', pargs['header_background'] or 'transparent')
:wikitext(header)
end
Line 266 ⟶ 273:
imagediv:wikitext(renderImageCell(img, w, heights[k],
pargs['link' .. i], pargs['alt' .. i],
pargs['thumbtime' .. i], pargs['caption' .. i], capalign, imgstyle, border))
end
end
Line 272 ⟶ 279:
-- add the footer
if( isnotempty(footer) ) then
local falign = string.lower(pargs['footer_align'] or args['footer_align'] or 'left')
falign = (falign == 'centre') and 'center' or falign
div:tag('div')
:addClass('trow')
:css('display', (falign ~= '') and 'flow-root' or 'flex')
:tag('div')
:addClass('thumbcaption' .. (falignborder =~= 'centerinfobox') and '-centerthumbcaption' or '')nil)
:css('text-align', (falign ~= 'left') and falign or nil)
:css('background-color', pargs['footer_background'] or 'transparent')
:wikitext(footer)
end
Administrators, verified
2,590

edits