Jump to content

Module:ImageRatio: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
function ratio()
function p.ratio(frame)
local file = frame.args[1] and mw.title.new('File:' .. mw.uri.decode(mw.ustring.gsub(frame.args[1],'%|.*$',''), 'WIKI'))
return '1'
file = file and file.file
w = tonumber(file.width) or 1
h = tonumber(file.height) or 1
local r = w/h
return r
end
end

Revision as of 09:54, 31 January 2024

function p.ratio(frame)
	local file = frame.args[1]  and mw.title.new('File:' .. mw.uri.decode(mw.ustring.gsub(frame.args[1],'%|.*$',''), 'WIKI'))
	file = file and file.file
	w = tonumber(file.width) or 1
	h = tonumber(file.height) or 1
    local r = w/h
	return r
end