Difference between revisions of "Template:ImageTG"
From Species-ID
(first try...) |
|||
Line 1: | Line 1: | ||
<includeonly><!-- | <includeonly><!-- | ||
** First store values for 100% scaling: ** | ** First store values for 100% scaling: ** | ||
− | -->{{#ifexpr:{{#pos:{{{1}}}|_10x.}} >0|<!--then-->{{#vardefine:tg_px1|589}}{{#vardefine:tg_label|200 µm}}}}<!-- | + | -->{{#ifexpr:{{#pos:{{{1}}}|_10x.}} > 0 |<!--then-->{{#vardefine:tg_px1|589}}{{#vardefine:tg_label|200 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_20x.}} >0|<!--then-->{{#vardefine:tg_px1|589}}{{#vardefine:tg_label|100 µm}}}}<!-- | + | -->{{#ifexpr:{{#pos:{{{1}}}|_20x.}} > 0 |<!--then-->{{#vardefine:tg_px1|589}}{{#vardefine:tg_label|100 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_40x.}} >0|<!--then-->{{#vardefine:tg_px1|595}}{{#vardefine:tg_label|50 µm}}}}<!-- | + | -->{{#ifexpr:{{#pos:{{{1}}}|_40x.}} > 0 |<!--then-->{{#vardefine:tg_px1|595}}{{#vardefine:tg_label|50 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_63x.}} >0|<!--then-->{{#vardefine:tg_px1|354}}{{#vardefine:tg_label|20 µm}}}}<!-- | + | -->{{#ifexpr:{{#pos:{{{1}}}|_63x.}} > 0 |<!--then-->{{#vardefine:tg_px1|354}}{{#vardefine:tg_label|20 µm}} }}<!-- |
− | -->{{#ifexpr:{{#pos:{{{1}}}|_100x.}}>0|<!--then-->{{#vardefine:tg_px1|295}}{{#vardefine:tg_label|10 µm}}}}<!-- | + | -->{{#ifexpr:{{#pos:{{{1}}}|_100x.}}> 0 |<!--then-->{{#vardefine:tg_px1|295}}{{#vardefine:tg_label|10 µm}} }}<!-- |
** The value above are correct for full size display, but need to be corrected for scaled images, relative to original imagewidth/desired imagewidth ** | ** The value above are correct for full size display, but need to be corrected for scaled images, relative to original imagewidth/desired imagewidth ** | ||
− | -->{{#vardefine:tg_px2| {{#expr: {{#var:tg_px1}} / {{ #if:{{#pos:{{{width|250px}}}|px}}|<!--then: is px-number, strip px ####NOT YET DONE!### and calculate ratio:-->{{#mediawidth:{{{1}}} }} / {{{width}}} |<!--else: %-number --> 100 / {{{width|100} | + | -->{{#vardefine:tg_px2| {{#expr: {{#var:tg_px1}} / {{#if: {{#pos:{{{width|250px}}}|px}}|<!--then: is px-number, strip px ####NOT YET DONE!### and calculate ratio:-->{{#mediawidth:{{{1}}} }} / {{{width}}} |<!--else: %-number --> 100 / {{{width|100}}} <!--endif-->}} }} <!--end vardefine:-->}}<!-- |
** Now insert into image template: ** | ** Now insert into image template: ** | ||
-->{{Image|{{{1|You must enter the image filename as a first parameter!}}} | -->{{Image|{{{1|You must enter the image filename as a first parameter!}}} | ||
Line 39: | Line 39: | ||
==Usage== | ==Usage== | ||
− | * <nowiki>{{ | + | * <nowiki>{{ImageTG|File:x.png|caption=Your caption text here|width=250px}}</nowiki> |
*: Fully equivalent to: <nowiki>[[File:x.png|250px|Your caption text here]]</nowiki> | *: Fully equivalent to: <nowiki>[[File:x.png|250px|Your caption text here]]</nowiki> | ||
− | * <nowiki>{{ | + | * <nowiki>{{ImageTG|File:x.png|thumb|left|width=15|upright|caption=Your caption text}}</nowiki> |
*: This scales the image to 15% of original size. | *: This scales the image to 15% of original size. | ||
</noinclude> | </noinclude> |
Revision as of 02:24, 17 December 2008
Description
This template is a specialized template to render a specific kind of microscopic photos by T. Gräfenhan. The images have a maximum size of 2560px if uncropped, but may be cropped. The major function of this template is to calculate a scale bar correctly for the magnification factors embedded in the file name.
Parameters
- width: either number + px for fixed width in pixel, or number, interpreted as percentage relative to original size.
- caption: You must pass the caption in a named parameter!
- a sequence of unnamed parameters, covering the standard image functionality (thumb, left, caption, etc.).
Usage
- {{ImageTG|File:x.png|caption=Your caption text here|width=250px}}
- Fully equivalent to: [[File:x.png|250px|Your caption text here]]
- {{ImageTG|File:x.png|thumb|left|width=15|upright|caption=Your caption text}}
- This scales the image to 15% of original size.
Dependendencies
Depends on Extension:StringFunctions, Extension:MediaFunctions, Extension:Variables.