(Page créée avec « <noinclude> If the filename is passed without its extension, will determine if a gif is available (defaults to png); returns the image; if file exists as neither gif nor p... ») |
(Annulation des modifications 179069 de Dinoxel (discussion)) Balise : Annulation |
||
(5 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
+ | <includeonly><!-- |
||
− | <noinclude> |
||
− | If the filename is passed without its extension, will determine if a gif is available (defaults to png); returns the image; if file exists as neither gif nor png, returns a null value. |
||
⚫ | |||
− | If the filename includes an extension, will return the image as normal. But you can prefixed it with a "?" character to check if the file exists, returning null if it doesn't. |
||
− | |||
− | ==Usage== |
||
− | <nowiki>{{image|options|caption}}</nowiki> |
||
− | The syntax is same as [[File:]]. |
||
− | |||
− | ==Parameters== |
||
− | All [[File:]] syntax are valid. |
||
− | |||
− | In addition: |
||
− | |||
⚫ | |||
− | Same as unamed size option, for convenience. Will be overrided by size option. e.g. <code>|20px|size=40px</code> will parse as <code>|20px</code> |
||
− | ;scale= |
||
− | Scale image based on its size. e.g. <code>scale=0.5</code>. |
||
− | |||
− | ;maxsize= |
||
− | Using same syntax as [[File:]]'s size option: <code>Wpx</code>, <code>Hpx</code>, or <code>WxHpx</code>. Note: this is applied AFTER scale. |
||
− | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
− | -->{{#vardefine:_imagename|}}<!-- |
||
⚫ | |||
-->{{#if:{{#pos:{{{1|}}}|.}}|<!-- |
-->{{#if:{{#pos:{{{1|}}}|.}}|<!-- |
||
− | -->{{ |
+ | -->{{image/info|{{{1|}}}|{{{force|}}}}}<!-- for "filename.ext" will do exist check. directly.(expensive) |
− | -->{{#vardefine:_imagename|{{trim|{{#sub:{{{1|}}}|1}}}}}}<!-- |
||
− | -->{{#ifexist: Media:{{#var:_imagename}}||{{#vardefine:_imagename|}}}}<!-- if not exist, unset. |
||
⚫ | |||
− | -->{{#vardefine:_imagename|{{{1}}}}}<!-- for "filename.ext" will use it directly. |
||
⚫ | |||
-->|<!-- |
-->|<!-- |
||
// for "filename" will check "filename.gif" and "filename.png" (expensive*2) |
// for "filename" will check "filename.gif" and "filename.png" (expensive*2) |
||
− | -->{{ |
+ | -->{{image/info|{{{1|}}}.gif|{{{force|}}}}}<!-- |
− | + | -->{{#if:{{#dplvar:_image_exist}}||<!-- |
|
− | + | -->{{image/info|{{{1|}}}.png|{{{force|}}}}}<!-- |
|
− | --> |
+ | -->}}<!-- |
− | + | -->}}<!-- |
|
⚫ | |||
− | -->{{#if:{{# |
+ | -->{{#if:{{#dplvar:_image_exist}}|<!-- |
− | -->{{#vardefine: |
+ | -->{{#vardefine:_size_argument|}}<!-- cache |
+ | //process all input argument |
||
− | -->[[File:{{#var:_imagename}}<!-- |
||
− | -->{{#vardefine:_outputstr|<!-- |
+ | -->{{#vardefine:_outputstr|<!-- string with all parameters of the "[[File:]]" call. fill it in the following loop |
− | -->{{#forargs:|_k|_v|<!-- |
+ | -->{{#forargs:|_k|_v|<!-- loop through all parameters |
− | -->{{#iferror:{{#expr:1+{{#var:_k}}}}|<!-- named parameter? |
+ | -->{{#iferror:{{#expr:1+{{#var:_k}}}}|<!-- check: is the parameter a named parameter? |
− | //named parameter |
+ | //parameter is a named parameter |
− | -->{{#switch:{{#var:_k}}<!-- |
+ | -->{{#switch:{{#var:_k}}<!-- check for certain parameters |
− | -->|maxsize|scale|size=<!-- skip, will process later. |
+ | -->|maxsize|scale|size=<!-- size options. skip, will process later. |
− | -->|#default={{!}}{{#var:_k}}={{#var:_v}}<!-- |
+ | -->|#default={{!}}{{#var:_k}}={{#var:_v}}<!-- other custom parameter. add "|<name of the parameter>=<value of the parameter>" to outputstring |
-->}}<!-- |
-->}}<!-- |
||
-->|<!-- |
-->|<!-- |
||
− | // |
+ | //parameter is an unnamed parameter |
-->{{#switch:{{#var:_k}}<!-- |
-->{{#switch:{{#var:_k}}<!-- |
||
− | -->|1=<!-- |
+ | -->|1=<!-- if parameter is the first unnamed parameter, then skip (is the image name info; already taken care of) |
− | -->|#default=<!-- |
+ | -->|#default=<!-- other unnamed parameters |
− | -->{{#ifeq:{{#sub:{{#var:_v}}|-2}}|px|<!-- is size option? |
+ | -->{{#ifeq:{{#sub:{{#var:_v}}|-2}}|px|<!-- is the parameter the size option? |
− | -->{{#vardefine: |
+ | -->{{#vardefine:_size_argument|{{#var:_v}}}}<!-- |
+ | -->|<!-- parameter is not the size option, but another (e.g. alt text or "thumb/frame/etc.") |
||
⚫ | |||
⚫ | |||
− | -->|<!-- |
||
⚫ | |||
-->}}<!-- |
-->}}<!-- |
||
-->}}<!-- |
-->}}<!-- |
||
Ligne 70 : | Ligne 37 : | ||
-->}}<!-- |
-->}}<!-- |
||
-->}}<!-- |
-->}}<!-- |
||
⚫ | |||
− | -->{{#if:{{{maxsize|}}}{{{scale|}}}{{{size|}}}|{{#if:{{#var:_size_outputed_flag}}||<!-- ($maxsize or $scale or $size) and !$flag |
||
− | + | -->{{#if:{{{maxsize|}}}{{{scale|}}}{{{size|}}}{{#var:_size_argument|}}|<!-- |
|
− | + | -->{{#vardefine:_outputstr|<!-- |
|
− | + | -->{{!}}<!-- |
|
⚫ | |||
+ | -->{{#var:_outputstr}}<!-- concatenate size parameters with other parameters |
||
⚫ | |||
⚫ | |||
+ | |||
+ | //final output: |
||
+ | -->[[File:{{#dplvar:_image_name}}{{#var:_outputstr}}]]<!-- |
||
-->}}<!-- |
-->}}<!-- |
||
+ | |||
− | --> |
||
+ | --></includeonly><noinclude><!-- |
||
+ | |||
+ | -->{{#cargo_declare:_table=Imageinfo |
||
+ | |image=String (size=200;mandatory) |
||
+ | |width=Integer |
||
+ | |height=Integer |
||
+ | |cached=Integer |
||
⚫ | |||
+ | |||
⚫ |
Version du 30 décembre 2020 à 00:11
Ce modèle définit la table « Imageinfo ». Afficher la table.
Documentation
[purger]
Aucune sous-page de documentation n'existe pour le moment pour ce modèle. En créer une maintenant.