Jump to content

Module:Main page image/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Coffeeandcrumbs (talk | contribs) at 17:13, 12 August 2020 (ce). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
--[[
local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.width(frame)
	local args = getArgs(frame)
	return p._width(args)
end

function p._width(args)
	local new_width = 140														
	local page = mw.title.makeTitle('File', args[1])
	if not page.fileExists then
		return new_width
	end

	local new_width = math.floor ( ( page.file.width / math.sqrt ( page.file.width * page.file.height ) ) + 0.5 )

	return new_width
end

return p
--]]