Module:FileInfo

From Moegirlpedia
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