Module:File/doc: Difference between revisions
From Neodyland Wiki
More actions
m umm |
m →From Lua: didym |
||
| Line 14: | Line 14: | ||
<source lang="Lua"> | <source lang="Lua"> | ||
local file = require( 'Module:File' ) | local file = require( 'Module:File' ) | ||
local fileObj = file.File( ' | local fileObj = file.File( 'File:Test.svg' ) | ||
local withoutExtension = fileObj.woExtension() | local withoutExtension = fileObj.woExtension() | ||
-- withoutExtension is now ' | -- withoutExtension is now 'Test' | ||
local exists = | local exists = fileObj.metadata().exists | ||
if exists then | if exists then | ||
mw.log( | mw.log( fileObj.metadata().width ) | ||
end | end | ||
</source> | </source> | ||
Revision as of 15:36, 10 February 2015
Scope
File title and file information. If the code here grows beyond a border line, this should be converted to an interface and the processing code should be outsourced.
Usage
From Wikitext
Search (Template:Key press) for @exports.
- Examples:
{{#invoke:File|extension|file=File:Test.jpg}}→jpg{{#invoke:File|width|file=File:Test.jpg}}→3120{{#invoke:File|dateWorkCreated|file=File:Ballot-sprite.png}}→{{#invoke:File|fileExists|file=File:Ballot-sprite.png}}→true
From Lua
local file = require( 'Module:File' )
local fileObj = file.File( 'File:Test.svg' )
local withoutExtension = fileObj.woExtension()
-- withoutExtension is now 'Test'
local exists = fileObj.metadata().exists
if exists then
mw.log( fileObj.metadata().width )
end