Module:Image array: Difference between revisions

no edit summary
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
 
Line 7: Line 7:
end
end


local function renderArrayCell(img, c, a, b, l, tc, t)
local function renderArrayCell( img, c, a, b, l, tc, t, w, h)
    local alt = isnotempty(a) and ('|alt=' .. a) or ''
local alt = isnotempty(a) and ('|alt=' .. a) or ''
    local link = isnotempty(l) and ('|link=' .. l) or ''
local link = isnotempty(l) and ('|link=' .. l) or ''
    local text = (isnotempty(tc) and not isnotempty(t)) and mw.text.unstrip(c) or mw.text.unstrip(t or '')
local text = (isnotempty(tc) and not isnotempty(t))  
    local border = isnotempty(b) and '|border' or ''
and mw.text.unstrip(c) or mw.text.unstrip(t or '')
   
local border = isnotempty(b) and '|border' or ''
    local cell = mw.html.create('')
    if img then
local cell = mw.html.create('')
        cell:tag('div')
if( img ) then
            :css('display', 'table-cell')
cell:tag('div')
            :css('vertical-align', 'middle')
:css('display', 'table-cell')
            :css('width', '140px')   -- Set the fixed width
:css('vertical-align', 'middle')
            :css('height', '140px') -- Set the fixed height
:css('width', w .. 'px')
            :css('margin', 'auto')
:css('height', h .. 'px')
            :wikitext(mw.ustring.format('[[File:%s|140x140px%s|%s]]', img, alt .. link .. border, text))
:css('margin-left', 'auto')
        cell:tag('div')
:css('margin-right', 'auto')
            :css('padding', '1px')
:wikitext(mw.ustring.format('[[File:%s|%dx%dpx%s|%s]]',  
            :wikitext(c)
img, w, h, alt .. link .. border, text))
    end
cell:tag('div')
   
:css('padding', '1px')
    return tostring(cell)
:wikitext(c)
end
return tostring(cell)
end
end