Module:File link/doc: Difference between revisions

From Mariopedia, a wiki on Mario, Yoshi, Wario, Donkey Kong, Super Smash Bros., and more!
Jump to navigationJump to search
no longer needed
(Undid revision 847393689 by Pppery (talk))
(no longer needed)
 
(5 intermediate revisions by 3 users not shown)
Line 1:
{{Module rating|protected}}
{{Lua|Module:Yesno|Module:Arguments}}
This module is used to construct wikitext links to files. It is primarily useful for templates and modules that use complicated logic to make file links. Simple file links should be made with wikitext markup directly, as it uses less resources than calling this module. For help with wikitext file markup please refer to the [[mw:Help:Images|documentation at mediawiki.org]].
 
== Usage from wikitext ==
 
From wikitext, this module should be called from a template, usually {{tl|file link}}. Please see the template page for documentation. However, it can also be called using the syntax <code><nowiki>{{#invoke:File link|main|</nowiki>''arguments''<nowiki>}}</nowiki></code>.
 
== Usage from Lua ==
Line 10 ⟶ 11:
First, you need to import the module.
 
<sourcesyntaxhighlight lang="lua">
local mFileLink = require('Module:File link')
</syntaxhighlight>
</source>
 
Then you can make file links using the <code>_main</code> function.
 
<sourcesyntaxhighlight lang="lua">
mFileLink._main(args)
</syntaxhighlight>
</source>
 
<var>args</var> is a table of arguments that can have the following keys:
Line 29 ⟶ 30:
* <code>size</code> - the size of the image, e.g. '100px', 'x100px' or '100x100px'.
* <code>upright</code> - the 'upright' parameter, used for setting the size of tall and thin images.
* <code>link</code> - the page that the file should link to. Use the blank string <nowiki>''</nowiki> to suppress the default link to the file description page.
* <code>alt</code> - the alt text. Use the blank string <nowiki>''</nowiki> to suppress the default alt text.
* <code>caption</code> - a caption for the file.
* <code>page</code> - sets a page number for multi-paged files such as PDFs.
Line 44 ⟶ 45:
 
With the file only:
<sourcesyntaxhighlight lang="lua">
mFileLink.main{file = 'Example.png'}
-- Renders as [[File:Example.png]]
</syntaxhighlight>
</source>
 
With format, size, link and caption options:
<sourcesyntaxhighlight lang="lua">
mFileLink.main{
file = 'Example.png',
Line 59 ⟶ 60:
}
-- Renders as [[File:Example.png|thumb|220px|link=Wikipedia:Sandbox|An example.]]
</syntaxhighlight>
</source>
 
With format, size, and border:
<sourcesyntaxhighlight lang="lua">
mFileLink.main{
file = 'Example.png',
Line 70 ⟶ 71:
}
-- Renders as [[File:Example.png|frameless|border|220px]]
</syntaxhighlight>
</source>
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu