‪TYPO3CMS  10.4
TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper:

Public Member Functions

 initializeArguments ()
 

Static Public Member Functions

static string renderStatic (array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 

Protected Attributes

bool $escapeChildren = false
 

Detailed Description

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}.

Definition at line 62 of file BytesViewHelper.php.

Member Function Documentation

◆ initializeArguments()

TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper::initializeArguments ( )

Initialize ViewHelper arguments

Definition at line 74 of file BytesViewHelper.php.

◆ renderStatic()

static string TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper::renderStatic ( array  $arguments,
\Closure  $renderChildrenClosure,
RenderingContextInterface  $renderingContext 
)
static

Render the supplied byte count as a human readable string.

Parameters
array$arguments
\Closure$renderChildrenClosure
\TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface$renderingContext
Returns
‪string Formatted byte count

Definition at line 92 of file BytesViewHelper.php.

References TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Member Data Documentation

◆ $escapeChildren

bool TYPO3\CMS\Fluid\ViewHelpers\Format\BytesViewHelper::$escapeChildren = false
protected

Output is escaped already. We must not escape children, to avoid double encoding.

Definition at line 69 of file BytesViewHelper.php.