Module:FileInfo

From Moegirlpedia
Revision as of 14:47, 2 January 2021 by 桂の脌 (talk | contribs) (Transport form zh.moegirl.org.cn)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Template-info.svg Module Documentation  [Create] [Refresh]
local module = {}

module.main = function(frame)
	local fileName = frame.args[1]
	local name = frame.args[2]
	local attrNames = { 'width', 'height', 'size', 'mimeType' }
	local title = mw.title.new('File:'..fileName)
	if title ~= nil then
		for i, v in ipairs(attrNames) do
			if v == name then
				return title.file[name]
			end
		end
		if (frame.args['w'] or '') ~= 'false' then
			error('Without this file attribute, the available file attributes include: width, height, size, and mimeType')
		end
	else
		if (frame.args['w'] or '') ~= 'false' then
			error('Do not have this file, please check the file name is correct!')	
		end
	end
end

return module