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