வார்ப்புரு:Px/doc
{{Documentation subpage}}
 &lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --&gt;
 __NOTOC__
 This is the {{tl|px}} template.
 
 This meta-template helps other templates, such as infoboxes, to take image size parameters in both of the forms &quot;40&quot; or &quot;40px&quot;. It takes up to three parameters and returns the first one that has any content. That is, the first one that is defined (not null) and not empty. Thus a default value for the width of the image can be fed as the second or third parameter.
 
 === Usage ===
 
 Here is what this template does. Code to the left, actual rendering to the right:
 
 :{{tlc|px|40}} = {{px|40}}
 :{{tlc|px|40px}} = {{px|40px}}
 
 And with an optional second or even third parameter to be used as a default value if the first or second parameter is empty or undefined:
 
 :{{tlc|px||50}} = {{px||50}}
 :{{tlc|px||50px}} = {{px||50px}}
 
 :{{tlc|px|||60}} = {{px|||60}}
 :{{tlc|px|||60px}} = {{px|||60px}}
 
 And here is how it can be used inside another template:
 
 :&lt;code&gt;&lt;nowiki&gt;[[Image:{{{image}}} | {{px|{{{size|}}}}} | {{{caption|}}} ]]&lt;/nowiki&gt;&lt;/code&gt;
 :&lt;code&gt;&lt;nowiki&gt;[[Image:{{{image}}} | {{px|{{{size|}}}|250}} | {{{caption|}}} ]]&lt;/nowiki&gt;&lt;/code&gt;
 :&lt;code&gt;&lt;nowiki&gt;[[Image:{{{image}}} | {{px| {{{size|}}} | {{{width|}}} | 250 }} | {{{caption|}}} ]]&lt;/nowiki&gt;&lt;/code&gt;
 
 === Default values ===
 
 It used to be a bit tricky to handle empty but defined image size values in a template, since the MediaWiki pipetrick doesn't return the default value for empty parameters. That is, &lt;code&gt;&lt;nowiki&gt;{{{width|250px}}}&lt;/nowiki&gt;&lt;/code&gt; does not return &quot;250px&quot; if the template was called like this: &lt;code&gt;&lt;nowiki&gt;{{template|width=}}&lt;/nowiki&gt;&lt;/code&gt;
 
 The usual workaround was to do like this: 
 :&lt;code&gt;&lt;nowiki&gt;{{#if:{{{width|}}}|{{{width}}}|250px}}&lt;/nowiki&gt;&lt;/code&gt;
 
 When at the same time handling the &quot;pxpx&quot; bug this became even more messy code:
 :&lt;code&gt;&lt;nowiki&gt;[[Image:{{{image}}} | {{#if:{{{width|}}}|{{px|{{{width}}}}}|250px}} ]]&lt;/nowiki&gt;&lt;/code&gt;
 
 To simplify the coding, {{tl|px}} allows for an optional default value to be defined allowing for the following:
 
 :&lt;code&gt;&lt;nowiki&gt;[[Image:{{{image}}} | {{px|{{{width|}}}|250}} ]]&lt;/nowiki&gt;&lt;/code&gt;
 
 '''Note!''' The parameters to {{tlf|px}} must use the pipe &quot;|&quot;, like this: &lt;code&gt;&lt;nowiki&gt;{{{width|}}}&lt;/nowiki&gt;&lt;/code&gt;. Or else {{tlf|px}} will be fed and return the string &quot;&lt;code&gt;&lt;nowiki&gt;{{{width}}}&lt;/nowiki&gt;&lt;/code&gt;&quot; if ''width'' was not defined.
 
 === Background ===
 
 Old usage was to always pad on &quot;px&quot; since MediaWiki used to tolerate &quot;40pxpx&quot;:
 
 :&lt;code&gt;&lt;nowiki&gt;[[Image:{{{image}}} | {{{size}}}px | {{{caption|}}} ]]&lt;/nowiki&gt;&lt;/code&gt;
 
 But since [[25 March]] [[2008]] that does not work anymore. That is, image sizes on Wikipedia now needs to be given in the form &quot;40px&quot;, not &quot;40&quot; or &quot;40pxpx&quot;. This template helps doing that. Note that the bug has since been fixed, although you can continue using this template.
 
 === See also ===
 
 * [[Wikipedia:ClickFix]] – About the &quot;pxpx&quot; bug.
 * {{tl|ifempty}} – Helps detect empty parameters and fall back to default values. For instance for handling multiple image name parameters.
 
 === Test examples ===
 
 * {{tlc|px|40}} = {{px|40}}
 * {{tlc|px|40px}} = {{px|40px}}
 * {{tlc|px|40pxpx}} = {{px|40pxpx}}
 * {{tlc|px|junk}} = {{px|junk}}
 * {{tlc|px}} = {{px}}
 * {{tlc|px|}} = {{px|}}
 * {{tlc|px||}} = {{px||}}
 * {{tlc|px|||}} = {{px|||}}
 * {{tlc|px|40|50}} = {{px|40|50}}
 * {{tlc|px||50}} = {{px||50}}
 * {{tlc|px||50px}} = {{px||50px}}
 * {{tlc|px||50|60}} = {{px||50|60}}
 * {{tlc|px|||60}} = {{px|||60}}
 * {{tlc|px|||60px}} = {{px|||60px}}
 
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | 50 | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png| 50 | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | 50pxpx | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | 50pxpx | thumb ]]
 ::Currently fails. But the devs have stated that they are adding back parsing of &quot;pxpx&quot; in the next update to Wikipedia. So if you see a small image to the right then Wikipedia again accepts &quot;pxpx&quot;.
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | 50px | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | 50px | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px|50}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px|50}} | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px|50px}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px|50px}} | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px|junk}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px|junk}} | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px|}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px|}} | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px}} | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px||50}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px||50}} | thumb ]]
 ::Giving the default width if the 1st parameter is empty 
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px|{{{width|}}}|50}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px|{{{width|}}}|50}} | thumb ]]
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px|{{{width}}}|50}} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px|{{{width}}}|50}} | thumb ]]
 ::Fails to use the default value of 50. Note the missing &quot;|&quot; in &lt;nowiki&gt;{{{width}}}&lt;/nowiki&gt;.
 &lt;br clear=all&gt;
 * &lt;code&gt;&lt;nowiki&gt;[[Image:Example.png | {{px| {{{width|}}} | {{{size|}}} | 50 }} | thumb ]]&lt;/nowiki&gt;&lt;/code&gt; = [[Image:Example.png | {{px| {{{width|}}} | {{{size|}}} | 50 }} | thumb ]]
 &lt;br clear=all&gt;
 
 &lt;includeonly&gt;
 &lt;!-- ADD CATEGORIES AND INTERWIKIS BELOW THIS LINE --&gt;
 [[Category:Wikipedia metatemplates|{{PAGENAME}}]]