Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:File/doc: Difference between revisions

From Neodyland Wiki
Usage: Note that an error is thrown, if the title can't be constructed (e.g. a title containing invalid characters is supplied) or meta data isn't available (e.g. due to missing file or extraction error).
m From Wikitext: new method "fileExistsRelaxed"
Line 15: Line 15:
::<code><nowiki>{{#invoke:File|dateWorkCreated|file=File:Ballot-sprite.png}}</nowiki></code> → <code>{{#invoke:File|dateWorkCreated|file=File:Ballot-sprite.png}}</code>
::<code><nowiki>{{#invoke:File|dateWorkCreated|file=File:Ballot-sprite.png}}</nowiki></code> → <code>{{#invoke:File|dateWorkCreated|file=File:Ballot-sprite.png}}</code>
::<code><nowiki>{{#invoke:File|fileExists|file=File:Ballot-sprite.png}}</nowiki></code> → <code>{{#invoke:File|fileExists|file=File:Ballot-sprite.png}}</code>
::<code><nowiki>{{#invoke:File|fileExists|file=File:Ballot-sprite.png}}</nowiki></code> → <code>{{#invoke:File|fileExists|file=File:Ballot-sprite.png}}</code>
::<code><nowiki>{{#invoke:File|fileExistsRelaxed|file=File:Ba[!#llot-sprite.png}}</nowiki></code> → <code>{{#invoke:File|fileExistsRelaxed|file=File:Ba[!#llot-sprite.png}}</code>


=== From Lua ===
=== From Lua ===

Revision as of 12:28, 26 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

Note that an error is thrown, if the title can't be constructed (e.g. a title containing invalid characters is supplied) or meta data isn't available (e.g. due to missing file or extraction error).

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|size|file=File:Test.jpg}}21003815
{{#invoke:File|mime|file=File:Test.jpg}}image/jpeg deprecated
{{#invoke:File|mimeType|file=File:Test.jpg}}image/jpeg
{{#invoke:File|dateWorkCreated|file=File:Ballot-sprite.png}}
{{#invoke:File|fileExists|file=File:Ballot-sprite.png}}true
{{#invoke:File|fileExistsRelaxed|file=File:Ba[!#llot-sprite.png}}

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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.