Format.bytes ViewHelper <f:format.bytes>
ViewHelper which formats an integer (byte count) into specific human-readable output.
Go to the source code of this ViewHelper: Format\BytesViewHelper.php (GitHub).
Table of contents
Examples
Simple
packages/my_extension/Resources/Private/Templates/Content/Text.fluid.html
{fileSize -> f:format.bytes()}
Copied!
Output
123 KB
Copied!
Depending on the value of {file.
With arguments
packages/my_extension/Resources/Private/Templates/Content/Text.fluid.html
{fileSize -> f:format.bytes(decimals: 2, decimalSeparator: '.', thousandsSeparator: ',')}
Copied!
Output
1,023.00 B
Copied!
Depending on the value of {file.
You may provide an own set of units, like this: B,KB,MB,GB,TB,PB,EB,ZB,YB.
Custom units
packages/my_extension/Resources/Private/Templates/Content/Text.fluid.html
{fileSize -> f:format.bytes(units: '{f:translate(\'viewhelper.format.bytes.units\', \'fluid\')}')}
Copied!
Output
123 KB
Copied!
Depending on the value of {file.
Arguments of the <f:format.bytes> ViewHelper
decimalSeparator
-
- Type
- string
- Default
- '.'
The decimal point character
decimals
-
- Type
- int
- Default
- 0
The number of digits after the decimal point
thousandsSeparator
-
- Type
- string
- Default
- ','
The character for grouping the thousand digits
units
-
- Type
- string
comma separated list of available units, default is LocalizationUtility::translate('viewhelper.format.bytes.units', 'fluid')
value
-
- Type
- int|float|string
The incoming data to convert, or NULL if VH children should be used