f:format.bytes

This ViewHelper converts a value in bytes (integer) into a readable format.

Properties

value

Variable type
Integer
Description
The integer value (bytes) to be converted.
Default value
NULL
Mandatory
No

decimals

Variable type
Integer
Description
The number of decimals to be shown after the decimal point.
Default value
0
Mandatory
No

decimalSeparator

Variable type
String
Description
The character to use as the decimal separator.
Default value
.
Mandatory
No

thousandsSeparator

Variable type
String
Description
The character to use as the “thousands” separator.
Default value
,
Mandatory
No

units

Variable type
String
Description
Comma separated list of available units.
Default value
LocalizationUtility::translate('viewhelper.format.bytes.units', 'fluid')
Mandatory
No

Examples

With a value of 1024.33, using the code

<f:format.bytes>{fileSize}</f:format.bytes>

will output

1024 KB

With decimal and thousands separator

{fileSize -> f:format.bytes(decimals: 2, decimalSeparator: '.', thousandsSeparator: ',')}

will output

1,023.00 B

You may provide an own set of units, like this: B,KB,MB,GB,TB,PB,EB,ZB,YB

{fileSize -> f:format.bytes(units: '{f:translate(\'viewhelper.format.bytes.units\', \'fluid\')}'

will output

123 KB