Module:Image array: Difference between revisions

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


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


local function imagearray( frame )
local function imagearray( frame )