Howto display the filesize next to a download link

feddersen
Community Manager
Community Manager
3 2 1,039

It's a common pratice in UI design to display the filesize next to a download link. That can be accomplished very easily within FirstSpirit.

Within a linktemplate, you can access the filesize like this:

$CMS_VALUE(ref(#link.sitestoreref).size)$

This will display the filesize in bytes, which isn't very userfriendly. However, we provide a convenience function for a human readable output:

$CMS_VALUE(ref(#link.sitestoreref).size.humanReadable("**","0.0 {U}"))$

This construct will output the filesize in the highest unit possible.

If you want to stick to a particular unit, kilobytes for example, you could do:

$CMS_VALUE(ref(#link.sitestoreref).size.humanReadable("KiB","0.0 {U}"))$

Possible units are:

KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB (base 2)

kB, MB, GB, TB, PB, EB, ZB, YB (base 10)

** will display the highest base 2 unit possible

* will display the highest base 10 unit possible

2 Comments
Version history
Last update:
‎05-27-2010 10:06 AM
Updated by: