Modulo:Immagine multipla/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
r
Moroboshi (discussione | contributi)
fix typo, aggiunti commenti, rivista funzione di recupero dimensioni dai metadata dei file
Riga 67:
end
 
--=====================================================
local function get_aspectratio(w, h, name)
-- Ritorna le dimensionei 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 all'altezza
--=====================================================
 
local function get_aspectratioget_dimensions(w, h, name)
local wr = w and tonumber(w)
local hr = h and tonumber(h)
Line 73 ⟶ 80:
local page = mw.title.new(name, 'Media')
if not wr then
wr = (page.file and page.file.width) or 200
end
if not hr then
hr = (page.file and page.file.height) or 200
end
end
wr = wr or 200
hr = hr or wr
return wr, hr
end
 
 
 
-- Return a sorted array of the index of the parameter immagine1 .. immagine(n)
Line 165 ⟶ 172:
local w = args['larghezza' .. imagenumbers[k]]
if totalwidth > 0 then
local wh = args['altezza' .. imagenumbers[k]]
widths[k], heights[k] = get_aspectratioget_dimensions(w, h, args['immagine' .. imagenumbers[k]])
else
widths[k] = (w and tonumber(w)) or width
Line 177 ⟶ 184:
 
-- if total_width has been specified, rescale the image widths
 
if totalwidth > 0 then
widthmax = 0
Line 189 ⟶ 195:
k = k + 1
if k<= imagecount then
local i = imagenumbers[k]
--local h = tonumber( args['altezza' .. i] or '' ) or 0
if (heights[k] > 0) then
ar[j] = widths[k]/heights[k]
--heights[k] = h
else
ar[j] = widths[k]/100