Modulo:Immagine multipla/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
r
Moroboshi (discussione | contributi)
r
Riga 66:
return prownum
end
 
local function get_aspectratio(w, h, name)
widths[k] local wr = (w and tonumber(w)) or width
local hr = h and tonumber(h)
if not(wr and hr) then
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
return wr, hr
end
 
 
 
-- Return a sorted array of the index of the parameter immagine1 .. immagine(n)
Line 139 ⟶ 156:
local widthmax = 0
local widthsum = {}
local heights = {}
local k = 0
for r=1,rowcount do
Line 146 ⟶ 164:
if k <= imagecount then
local w = args['larghezza' .. imagenumbers[k]]
if totalwidth > 0 then
widths[k] = (w and tonumber(w)) or width
local w = args['altezza' .. imagenumbers[k]]
widths[k], heights[k] = get_aspectratio(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 ⟶ 177:
 
-- if total_width has been specified, rescale the image widths
 
local heights = {}
if totalwidth > 0 then
widthmax = 0
Line 167 ⟶ 190:
if k<= imagecount then
local i = imagenumbers[k]
--local h = tonumber( args['altezza' .. i] or '' ) or 0
if (hheights[k] > 0) then
ar[j] = widths[k]/hheights[k]
--heights[k] = h
else
ar[j] = widths[k]/100
Line 280 ⟶ 303:
end
 
--inerfacciainterfaccia verso il template immagine multipla
function p.render( frame )
local getArgs = require('Module:Arguments').getArgs
Line 288 ⟶ 311:
end
--inerfacciainterfaccia verso template più specifici ({{Doppia immagine}}, {{tripla immagine}}...)
function p.render_parentrender_frame( frame )
local getArgs = require('Module:Arguments').getArgs
--local pargs = getArgs(frame, {parentOnly=true})
local args = getArgs(frame, {frameOnly=true})
return p._render( args )