Modulo:Immagine multipla: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
fix conversione totalwidth |
semplifico il codice |
||
Riga 1:
-- implements [[template:multiple image]]
local p = {}
local function renderImageCell(image, width, height, link, alt, caption, textalign, istyle)
Line 21 ⟶ 17:
end
imagediv:wikitext('[[file:' .. image .. widthstr .. linkstr .. altstr .. ']]')
if
local captiondiv = root:tag('div')
captiondiv:addClass('thumbcaption')
captiondiv:css('clear', 'left')
if
captiondiv:css('text-align', textalign)
end
Line 35 ⟶ 31:
local function getWidth(w1, w2)
local w
if
end
return
end
Line 69 ⟶ 63:
-- passed to the template. Index could be not consecutive but the gap between
-- different index must be five or less
local function getImageNumbers(
local imagenumbers = {}
local istart = 1
Line 77 ⟶ 71:
local found = false
for i=istart, iend do
if
imagenumbers[#imagenumbers+1] = i
found = true
Line 93 ⟶ 87:
end
local width =
local dir =
local align =
local capalign =
local totalwidth =
local imgstyle = args['stile immagine']
local
local
local perrow = nil
local thumbclass = {
Line 118 ⟶ 111:
-- find all the nonempty images
local imagenumbers = getImageNumbers(
local imagecount = #imagenumbers
if imagecount == 0 then
Line 128 ⟶ 121:
perrow = getPerRow('1', imagecount)
else
perrow = getPerRow(
end
Line 145 ⟶ 138:
if( k <= imagecount ) then
local i = imagenumbers[k]
widths[k] = getWidth(width,
widthsum[r] = widthsum[r] + widths[k]
end
Line 166 ⟶ 159:
if( k<= imagecount ) then
local i = imagenumbers[k]
local h = tonumber(
if (h > 0) then
ar[j] = widths[k]/h
Line 207 ⟶ 200:
bodywidth = math.max( 100, bodywidth - 8);
local bg =
-- create the array of images
local root = mw.html.create('div')
Line 216 ⟶ 209:
if( align == 'center' or align == 'centre' or align == 'centro') then
root:addClass('center')
end
if( bg ~= '' ) then
Line 235 ⟶ 222:
end
-- add the header
if
div:tag('div')
:css('clear', 'both')
:css('text-align',
:css('background-color',
:wikitext(header)
end
Line 258 ⟶ 245:
imagediv:css('margin', '1px')
local i = imagenumbers[k]
local img =
local w = widths[k]
imagediv:css('width', tostring(2 + w) .. 'px')
:css('max-width', tostring(2 + w) .. 'px')
imagediv:wikitext(renderImageCell(img, w, heights[k],
end
end
Line 274 ⟶ 261:
end
-- add the footer
if
div:tag('div')
:addClass('thumbcaption')
:css('clear', 'left')
:css('text-align',
:css('background-color',
:wikitext(footer)
end
Line 289 ⟶ 276:
function p.render( frame )
local getArgs = require('Module:Arguments').getArgs
--local pargs = getArgs(frame, {parentOnly=true})
local args = getArgs(frame
return
end
|