Template talk:Item Statistics

From HorizonXI Wiki

Code behaviour of the icon id field

Code

add a table div to display the item card statistics. if the icon file exists, style it with a border and padding
--><div style="display:table; {{#ifexist:File:{{5Digit|{{{icon id|}}}}}.png|min-width:359px; border:1px solid #aaa; border-radius:5px; padding-right:5px;}}"><!--

if the icon file exists, add it using the superimpose template which puts it on a standard background
-->{{#ifexist:File:{{5Digit|{{{icon id|}}}}}.png|<div style="display:table-cell; width:32px; padding:1ex;">{{Superimpose|base=icon background.png|base_width=32px|float={{5Digit|{{{icon id|}}}}}.png|float_width=32px|x=0|y=0}}</div>}}<!--

Behavior

The 5Digit function expects a 1-5 digit number and returns that number as a 5 digit number, padded with leading zeroes if necessary. If the input is not a 1-5 digit number, the function returns "5D plz" as string.

The code then appends ".png" and the ifexists check looks for that file.

this results in the following behavior wrt the icon id field:

  1. if a 1-5 digit icon id is provided, which DOES correspond to an existing file (e.g. 12345 and 12345.png exists), then the table div is styled with a border and padding and the icon is inserted.
  2. if a 1-5 digit icon id is provided which DOES NOT correspond to an existing file (e.g. 12345 and 12345.png does not exist), then the 5Digit function correctly returns that number adequately padded but the ifexists check fails. Thus the table div is not styled with border and padding and no icon is displayed.
  3. if the icon id field is omitted entirely, the 5Digit function returns "5D plz", this is appended with .png and the ifexists looks for "5D_plz.png". If a file has been uploaded the with that name, the ifexist check succeeds and styles the table div with border and padding, along with displaying the "5D_plz.png" icon. This causes the "5D_plz.png" icon to effectively act as a default image when no icon id is given.