Template:Px
This is the {{px}} meta-template.
It helps other templates, such as infoboxes, to take image size parameters in both of the forms "40" or "40px". 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[edit source]
Here is what this template does. Code to the left, actual rendering to the right:
- Template:Tlc = 40px
- Template:Tlc = 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:
- Template:Tlc = 50px
- Template:Tlc = 50px
- Template:Tlc = 60px
- Template:Tlc = 60px
And here is how it can be used inside another template:
[[Image:{{{image}}} | {{px|{{{size|}}}}} | {{{caption|}}} ]]
[[Image:{{{image}}} | {{px|{{{size|}}}|250}} | {{{caption|}}} ]]
[[Image:{{{image}}} | {{px| {{{size|}}} | {{{width|}}} | 250 }} | {{{caption|}}} ]]
Note! The parameters to Template:Tlf must use the pipe "|", like this: {{{width|}}}
. Or else Template:Tlf will be fed and return the string "{{{width}}}
" if width was not defined.