विभाग:File/doc
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). It is your responsibility to catch them; in Lua through pcall()
; from Wikitext as {{#iferror: {{#invoke:File|function|file=File:P%bar]baz.qqq}} | meaningful message}}
.
From Wikitext
संपादनSearch (Ctrl+F) for @exports
.
- Examples:
{{#invoke:File|woExtension|file=File:Test.C.JpeG}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|extension|file=File:Test.C.JpeG}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|csExtension|file=File:Test.C.JpeG}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|width|file=File:Test.jpg}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|dimensions|file=File:Test.jpg}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|size|file=File:Test.jpg}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|mime|file=File:Test.jpg}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
deprecated (but works even if the file does not exist and has no metadata){{#invoke:File|mimeType|file=File:Test.jpg}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
preferred (but will not work if the file does not exist to parse its metadata){{#invoke:File|mime|file=File:DOESNOTEXIST-0a8de8c83.Png}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|mimeType|file=File:DOESNOTEXIST-0a8de8c83.Png}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|dateWorkCreated|file=File:Ballot-sprite.png}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|fileExists|file=File:Ballot-sprite.png}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|fileExists|file=File:DOESNOTEXIST-0a8de8c83.png}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
{{#invoke:File|fileExistsRelaxed|file=File:Ba[!#llot-sprite.png}}
→लुआ(Lua) त्रुटी package.lua मध्ये 80 ओळीत: module 'Module:HTMLParser' not found.
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