Modulo:Immagine multipla/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
r |
r |
||
Riga 66:
return prownum
end
local function get_aspectratio(w, h, name)
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 (
ar[j] = widths[k]/
--heights[k] = h
else
ar[j] = widths[k]/100
Line 280 ⟶ 303:
end
--
function p.render( frame )
local getArgs = require('Module:Arguments').getArgs
Line 288 ⟶ 311:
end
--
function p.
local getArgs = require('Module:Arguments').getArgs
local args = getArgs(frame, {frameOnly=true})
return p._render( args )
|