Modulo:Immagine multipla: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
fix
Evita background-color: transparent, non funziona bene con la night mode. Impostando il valore a nil la proprietà viene omessa del tutto.
 
(7 versioni intermedie di 3 utenti non mostrate)
Riga 9:
--=====================================================
-- Generazione del codice una singola cella contenente
-- un immmagine'immagine
--=====================================================
local function renderImageCell(image, width, height, link, alt, caption, textalign, istyle)
Riga 65:
end
return prownum
end
 
--=====================================================
-- Ritorna le dimensioni dell'immagine (larghezza x altezza)
-- Se queste non sono passate dai parametri tenta di recuperarle
-- dalle informazioni del file immagine, altrimenti ricade su
-- una larghezza pari a 200 e un'altezza pari alla larghezza
--=====================================================
 
local function get_dimensions(w, h, name)
widths[k] local wr = (w and tonumber(w)) or width
local hr = h and tonumber(h)
if not(hwr >and 0hr) then
local page = mw.title.new(name, 'Media')
if bgnot wr then
wr = page.file and page.file.width
end
if bgnot ~= ''hr then
hr = page.file and page.file.height
end
end
wr = wr or 200
hr = hr or wr
return wr, hr
end
 
Line 84 ⟶ 108:
end
if found then
istart = istartiend + istep1
iend = iend + istep
else
Line 139 ⟶ 163:
local widthmax = 0
local widthsum = {}
local heights = {}
local k = 0
for r=1,rowcount do
Line 146 ⟶ 171:
if k <= imagecount then
local w = args['larghezza' .. imagenumbers[k]]
if totalwidth > 0 then
widths[k] = (w and tonumber(w)) or width
local h = tonumber( args['altezza' .. iimagenumbers[k]] or '' ) or 0
widths[k], heights[k] = get_dimensions(w, h, args['immagine' .. imagenumbers[k]])
else
widths[k] = (w and tonumber(w)) or width
end
widthsum[r] = widthsum[r] + widths[k]
end
Line 154 ⟶ 184:
 
-- if total_width has been specified, rescale the image widths
local heights = {}
if totalwidth > 0 then
widthmax = 0
Line 166 ⟶ 195:
k = k + 1
if k<= imagecount then
localif i = imagenumbers(heights[k] > 0) then
ar[j] = widths[k]/hheights[k]
local h = tonumber( args['altezza' .. i] or '' ) or 0
if (h > 0) then
ar[j] = widths[k]/h
heights[k] = h
else
ar[j] = widths[k]/100
Line 201 ⟶ 227:
local bodywidth = 0
for r=1,rowcount do
local bw = widthsum[r] + 4 * (perrow[r] - 1) + 122
bodywidth = math.max(bodywidth, bw)
end
Line 207 ⟶ 233:
bodywidth = math.max( 100, bodywidth);
 
local bg = args['sfondo']
-- crea il div esterno per la galleria di immagini
local root = mw.html.create('div')
root:addClass('thumb')
root:addClass(thumbclass[align] or 'tright')
root:css('width', tostring(bodywidth) .. 'px')
-- :css('max-width', tostring(bodywidth) .. 'px')
if align == 'center' or align == 'centre' or align == 'centro' then
root:css('margin', '0 auto')
end
if bg then root:css('background-color', bg) end
-- crea il div interno
local div = root:tag('div')
div:addClass('thumbinner')
if bg then
div:css('background-colorwidth', bgtostring(bodywidth+2) .. 'px')
:css('clearflex-direction', 'leftrow')
if align == 'center' or align == 'centre' or align == 'centro' then
rootdiv:css('margin', '0 auto')
end
div:addClass('thumbinner')
if bg then div:css('background-color', bg) end
-- aggiunge il titolo
if header then
Line 230 ⟶ 250:
:css('clear', 'both')
:css('text-align', args['allinea titolo'] or 'center')
:css('background-color', args['sfondo titolo'] or 'transparent')
:wikitext(header)
end
Line 243 ⟶ 263:
if dir ~= 'vertical' then
imagediv:css('float', 'left')
end
if bg ~= '' then
imagediv:css('background-color', bg);
end
imagediv:css('margin', '1px')
Line 260 ⟶ 277:
end
end
-- only float content gives a parent height:0, so add a clearing div
div:tag('div'):css('clear', 'left')
if dir ~= 'vertical' and dir ~= 'verticale' then
div:tag('div')
:css('clear', 'left')
end
end
-- add the footer
Line 272 ⟶ 286:
:css('clear', 'left')
:css('text-align', args['allinea sotto'] or 'left')
:css('background-color', args['sfondo sotto'] or 'transparent')
:wikitext(footer)
end
return tostring(root)