Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Format.bytes ViewHelper <f:format.bytes>
Formats an integer with a byte count into human readable form.
Examples
Simple
{fileSize -> f:format.bytes()}
123 KB
Depending on the value of {fileSize}
.
With arguments
{fileSize -> f:format.bytes(decimals: 2, decimalSeparator: '.', thousandsSeparator: ',')}
1,023.00 B
Depending on the value of {fileSize}
.
You may provide an own set of units, like this: B,KB,MB,GB,TB,PB,EB,ZB,YB
.
Custom units
{fileSize -> f:format.bytes(units: '{f:translate(\'viewhelper.format.bytes.units\', \'fluid\')}'
123 KB
Depending on the value of {fileSize}
.
Source code
Go to the source code of this ViewHelper: BytesViewHelper.php (GitHub).
Arguments
The following arguments are available for <f:
:
value
-
- Type
- mixed
The incoming data to convert, or NULL if VH children should be used
decimals
-
- Type
- mixed
The number of digits after the decimal point
decimalSeparator
-
- Type
- string
- Default
'.'
The decimal point character
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')