I am still trying to figure out what exactly it is you want it to do. At this time it seems like your script won't ever add the .gif extension. It reads the avatar-parameter, when it is not empty, .png will be added. When it is empty, .gif will be added. This won't ever work because the only case you will get .gif as output would be when there was no image inserted at all.

  1. if: works this way:

{{#if: test string | value if test string is not empty | value if test string is empty}}

If you want to check what extension avatar has, use {{#sub:{{{avatar}}}|-3}} This will return the last 3 characters of avatar, which would be the png, jpg and gif suffixes. From there on, you can use these for if-statements or switch-cases, any way you prefer.

I feel I haven't answered your question yet, so I would like to see some more information on how you want to use this. Link to example pages where possible.

Community content is available under CC-BY-SA unless otherwise noted.