<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.limswiki.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AFile_link%2Fdoc</id>
	<title>Module:File link/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.limswiki.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AFile_link%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.limswiki.org/index.php?title=Module:File_link/doc&amp;action=history"/>
	<updated>2026-10-21T15:37:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://www.limswiki.org/index.php?title=Module:File_link/doc&amp;diff=16564&amp;oldid=prev</id>
		<title>Shawndouglas: Created as needed.</title>
		<link rel="alternate" type="text/html" href="https://www.limswiki.org/index.php?title=Module:File_link/doc&amp;diff=16564&amp;oldid=prev"/>
		<updated>2014-11-22T16:40:02Z</updated>

		<summary type="html">&lt;p&gt;Created as needed.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This module is used to construct wikitext links to files, using a fluent Lua interface. This is done by creating a &amp;lt;var&amp;gt;fileLink&amp;lt;/var&amp;gt; object, which has various methods corresponding to different file link parameters. The module is used from other Lua modules, and cannot be used directly from wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
=== Creating the object ===&lt;br /&gt;
&lt;br /&gt;
First, you need to import the module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local fileLink = require(&amp;#039;Module:File link&amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, create the object using the &amp;lt;code&amp;gt;fileLink.new&amp;lt;/code&amp;gt; function. The first parameter is the filename, and is optional.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local obj = fileLink.new(&amp;#039;Example.png&amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Basic usage ===&lt;br /&gt;
&lt;br /&gt;
You can add parameters to the file link using the fileLink object&amp;#039;s methods. (See [[#Methods|the Methods section]] below for the full list.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:width(220)&lt;br /&gt;
obj:alt(&amp;#039;The alt text&amp;#039;)&lt;br /&gt;
obj:caption(&amp;#039;The caption.&amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then produce the link wikitext using the object&amp;#039;s &amp;lt;code&amp;gt;render&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:render()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will produce the following wikitext:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[File:Example.png|220px|alt=The alt text|The caption.]]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Call-chaining ===&lt;br /&gt;
&lt;br /&gt;
All the object&amp;#039;s methods apart from the &amp;lt;code&amp;gt;render&amp;lt;/code&amp;gt; method return the object itself, so can be used to call-chain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:width(220):alt(&amp;#039;The alt text&amp;#039;):caption(&amp;#039;The caption.&amp;#039;):render()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; method, all of the object&amp;#039;s methods support nil as an input, so call-chaining can be performed with variables whose value is unknown. However, an error will be raised if the input is of an unsupported type for that method. Please see [[#Methods|the Methods section]] for supported input types for each method. Passing nil to a method will overwrite any existing values.&lt;br /&gt;
&lt;br /&gt;
=== Use with tostring ===&lt;br /&gt;
&lt;br /&gt;
Instead of using the &amp;lt;code&amp;gt;render&amp;lt;/code&amp;gt; method, you can call &amp;lt;code&amp;gt;tostring&amp;lt;/code&amp;gt; on the object to create the link wikitext.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:width(220):alt(&amp;#039;The alt text&amp;#039;):caption(&amp;#039;The caption.&amp;#039;)&lt;br /&gt;
tostring(obj)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
=== Name ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:name(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the filename. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must be a string. Nil values are not accepted, as every file link requires a filename. The filename can also be set in the first parameter to &amp;lt;code&amp;gt;fileLink.new&amp;lt;/code&amp;gt;, although in that case it is optional.&lt;br /&gt;
&lt;br /&gt;
=== Format ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:format(s, filename)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the display format. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil, or one of the strings &amp;#039;thumb&amp;#039;, &amp;#039;thumbnail&amp;#039;, &amp;#039;frame&amp;#039;, &amp;#039;framed&amp;#039;, or &amp;#039;frameless&amp;#039;. To see the effect of each of these values, see the [[mw:Help:Images#Format|images help page on mediawiki.org]]. Note that the &amp;#039;&amp;#039;border&amp;#039;&amp;#039; format is not set with this method, but with the [[#Border|border method]]. (This is because the border option can be set independently of the values that can be set with this method, for example in the code &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[File:Example.png|frameless|border|caption]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.)&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;var&amp;gt;filename&amp;lt;/var&amp;gt; variable is an optional variable that can be used to set the filename for thumbnails. The filename specified will be used instead of the automatically generated thumbnail. This option doesn&amp;#039;t have any effect on the other format options.&lt;br /&gt;
&lt;br /&gt;
=== Border ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:border(hasBorder)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a border for images. &amp;lt;var&amp;gt;hasBorder&amp;lt;/var&amp;gt; must either be nil, or a boolean value. A border will be set if &amp;lt;var&amp;gt;hasBorder&amp;lt;/var&amp;gt; is true. To see the effect of this option, see the [[mw:Help:Images#Format|images help page on mediawiki.org]].&lt;br /&gt;
&lt;br /&gt;
=== Width ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:width(px)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a width for the file in pixels. &amp;lt;var&amp;gt;px&amp;lt;/var&amp;gt; must either be nil or a number value. Width can be used in conjunction with the [[#Height|height method]], but will produce an error if used when the &amp;#039;&amp;#039;upright&amp;#039;&amp;#039; option has been set by the [[#Upright|upright method]].&lt;br /&gt;
&lt;br /&gt;
=== Height ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:height(px)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a height for the file in pixels. &amp;lt;var&amp;gt;px&amp;lt;/var&amp;gt; must either be nil or a number value. Height can be used in conjunction with the [[#Width|width method]], but will produce an error if used when the &amp;#039;&amp;#039;upright&amp;#039;&amp;#039; option has been set by the [[#Upright|upright method]].&lt;br /&gt;
&lt;br /&gt;
=== Upright ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:upright(isUpright, factor)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the &amp;#039;&amp;#039;upright&amp;#039;&amp;#039; option, used for images that are taller than they are wide. &amp;lt;var&amp;gt;isUpright&amp;lt;/var&amp;gt; must either be nil, or a boolean value. The upright option will be set if &amp;lt;var&amp;gt;isUpright&amp;lt;/var&amp;gt; is true. &amp;lt;var&amp;gt;factor&amp;lt;/var&amp;gt; provides an optional conversion factor for the upright option; the factor is the image&amp;#039;s width divided by its height. If no factor is specified, the MediaWiki software uses the default of 0.75. &amp;lt;var&amp;gt;factor&amp;lt;/var&amp;gt; must be either nil or a number value. If a width or height has been set with the [[#Width|width]] or [[#Height|height]] methods, then setting the upright value will result in an error.&lt;br /&gt;
&lt;br /&gt;
=== ResetSize ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:resetSize()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method clears any size-related data the fileLink object is holding. This includes width, height, the upright option, and any upright factor.&lt;br /&gt;
&lt;br /&gt;
=== Location ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:location(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the &amp;#039;&amp;#039;location&amp;#039;&amp;#039; option. This is also known as the &amp;#039;&amp;#039;horizontal alignment&amp;#039;&amp;#039; option. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil, or one of the strings &amp;#039;right&amp;#039;, &amp;#039;left&amp;#039;, &amp;#039;center&amp;#039;, or &amp;#039;none&amp;#039;. To see the effect of each of these values, see the [[mw:Help:Images#Horizontal alignment|images help page on mediawiki.org]].&lt;br /&gt;
&lt;br /&gt;
=== Alignment ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:alignment(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the &amp;#039;&amp;#039;alignment&amp;#039;&amp;#039; option. This is also known as the &amp;#039;&amp;#039;vertical alignment&amp;#039;&amp;#039; option. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil, or one of the strings &amp;#039;baseline&amp;#039;, &amp;#039;middle&amp;#039;, &amp;#039;sub&amp;#039;, &amp;#039;super&amp;#039;, &amp;#039;text-top&amp;#039;, &amp;#039;text-bottom&amp;#039;, &amp;#039;top&amp;#039;, or &amp;#039;bottom&amp;#039;. To see the effect of each of these values, see the [[mw:Help:Images#Vertical alignment|images help page on mediawiki.org]].&lt;br /&gt;
&lt;br /&gt;
=== Link ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:link(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a link target for the file, instead of the default target of the file description page. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil or a string value. The link can be a wiki page or a URL, although the exact formatting of the string is not checked by this module. To specify no link, use the blank string: {{code|obj:link(&amp;#039;&amp;#039;)|lua}}.&lt;br /&gt;
&lt;br /&gt;
=== Alt ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:alt(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets [[WP:ALT|alt text]] for the file. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil or a string value.&lt;br /&gt;
&lt;br /&gt;
=== Page ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:page(num)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a page number for multi-paged files such as PDFs. &amp;lt;var&amp;gt;num&amp;lt;/var&amp;gt; must either be nil or a number.&lt;br /&gt;
&lt;br /&gt;
=== Class ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:class(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a &amp;lt;code&amp;gt;class&amp;lt;/code&amp;gt; parameter to image links. The MediaWiki software adds this parameter to the &amp;lt;code&amp;gt;class=&amp;quot;...&amp;quot;&amp;lt;/code&amp;gt; attribute of the image&amp;#039;s &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;img /&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; element when the page is rendered into HTML. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil or a string value.&lt;br /&gt;
&lt;br /&gt;
=== Lang ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:lang(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a language attribute to specify what language to render the file in. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil or a string value. This module does not check whether the language tag is valid or not.&lt;br /&gt;
&lt;br /&gt;
=== StartTime ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:startTime(time)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifies a start time for audio and video files. &amp;lt;var&amp;gt;time&amp;lt;/var&amp;gt; must be nil, a number, or a string value. Numbers are interpreted as the number of seconds since the start of the file. Strings can be in the format &amp;quot;&amp;#039;&amp;#039;mm&amp;#039;&amp;#039;:&amp;#039;&amp;#039;ss&amp;#039;&amp;#039;&amp;quot; to specify the number of minutes and seconds of a file, or &amp;quot;&amp;#039;&amp;#039;ss&amp;#039;&amp;#039;&amp;quot; to specify the number of seconds since the start of the file.&lt;br /&gt;
&lt;br /&gt;
=== EndTime ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:endTime(time)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifies an end time for audio and video files. &amp;lt;var&amp;gt;time&amp;lt;/var&amp;gt; must be nil, a number, or a string value. Numbers are interpreted as the number of seconds since the start of the file. Strings can be in the format &amp;quot;&amp;#039;&amp;#039;mm&amp;#039;&amp;#039;:&amp;#039;&amp;#039;ss&amp;#039;&amp;#039;&amp;quot; to specify the number of minutes and seconds of a file, or &amp;quot;&amp;#039;&amp;#039;ss&amp;#039;&amp;#039;&amp;quot; to specify the number of seconds since the start of the file.&lt;br /&gt;
&lt;br /&gt;
=== ThumbTime ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:thumbTime(time)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifies the time to use to generate the thumbnail image for video files. &amp;lt;var&amp;gt;time&amp;lt;/var&amp;gt; must be nil, a number, or a string value. Numbers are interpreted as the number of seconds since the start of the file. Strings can be in the format &amp;quot;&amp;#039;&amp;#039;mm&amp;#039;&amp;#039;:&amp;#039;&amp;#039;ss&amp;#039;&amp;#039;&amp;quot; to specify the number of minutes and seconds of a file, or &amp;quot;&amp;#039;&amp;#039;ss&amp;#039;&amp;#039;&amp;quot; to specify the number of seconds since the start of the file.&lt;br /&gt;
&lt;br /&gt;
=== Caption ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:caption(s)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a caption for the file. &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; must either be nil or a string value.&lt;br /&gt;
&lt;br /&gt;
=== Render ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
obj:render()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Renders the link wikitext.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox||&lt;br /&gt;
&amp;lt;!-- Categories go here and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Shawndouglas</name></author>
	</entry>
</feed>