Modul:Image
Vzhled
local p = {}
local function parseProportions(str)
str = mw.text.trim(str or '')
str = string.gsub(str, 'px$', '', 1)
local parts = mw.text.split(str, 'x', true)
local width, height = tonumber(parts[1]), tonumber(parts[2])
return width, height
end
function p.countFullWidth(frame)
local files = mw.text.split(frame.args[1], '#', true)
local proportions = mw.text.split(frame.args[2], '#', true)
local border = tonumber(frame.args[3]) or 0
local spacing = tonumber(frame.args[4]) or 0
local propsTable = {}
for i, file in ipairs(files) do
local width, height = parseProportions(proportions[i])
if width == nil then
local fileTitle = mw.title.makeTitle('File', file)
width = math.ceil((height / fileTitle.file.height) * fileTitle.file.width)
end
table.insert(propsTable, width)
end
if frame.args['orientation'] == 'portrait' then
local resultTable = {}
for k, v in pairs(propsTable) do
resultTable[v] = 0
end
return table.maxn(resultTable) + border
else
local fullWidth = 0
local count = #propsTable
for i = 1, count do
fullWidth = fullWidth + propsTable[i]
end
return fullWidth
+ count * border
+ (count - 1) * spacing
end
end
return p