Module:File info
Appearance
Documentation for this module may be created at Module:File info/doc
local p = {}
function getFileData( frame )
local title = frame.args.title or ''
if title == '' then
return '<span class="error">"title" parameter not set</span>'
end
return mw.title.new( title, 'File' ).file
end
function p.fileNumberOfPages(frame)
local file = getFileData( frame )
if not file.exists then
return ''
end
if file.pages == nil then
return 1
end
return #file.pages
end
function p.fileFormattedSize(frame)
local file = getFileData( frame )
if not file.exists then
return ''
end
local size = getFileData( frame ).size or 0
return mw.getContentLanguage():formatNum(size)
end
return p