Showing - INT(4) - UNSIGNED ZEROFILL as "0001" and not "1"

i have a field called.

image_start_number
int(4)
Attributes UNSIGNED ZEROFILL

So basically instead of showing “1” in the database… it shows say “0001”

But when I place it on my page via sever connect i get {{serverconnect1.data.query1[0].image_start_number}} it comes out as just “1”

The reason is i have a dynamic gallery… but the images gets uploaded via FTP because there might be a 1000 at a time… so what i want to achieve …

{{serverconnect1.data.query1[0].image_start_number + $index}}

So it becomes 0001,0002,0003 and so on…

but at this point of time it only makes 1,2,3,4… and so on…

How do i achieve this … how do i get {{serverconnect1.data.query1[0].image_start_number}} to render as in the databse table… as 0001 and not just 1…

dmx-bind:href="{{serverconnect1.data.query1[0].image_prefix}}{{serverconnect1.data.query1[0].image_start_number + $index}}.jpg"

so it becomes… DSC_0001.jpg,DSC0002.jpg,DSC0003.jpg

Or am i overthinking this…

Hey Reinhardt,
There is a special formatter for such cases, available for numeric values. It’s available under numbers and it’s called Pad:

So it adds .pad(4) after your value.
Example: {{serverconnect1.data.query1[0].image_start_number.pad(4)}}

1 Like

Thank you for the quick reply Teodor

cool… if anyone wants to add the $index + a value…

{{($index + serverconnect1.data.query1[0].image_start_number).pad(4)}}

then it will become this…

0017 0018 0019 0020 0021 0022 0023 0024 0025 0026 0027 0028 0029 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 0040 0041

Thank you for the help Teodor.

1 Like