wp_size_format()

Twig function of the framework; its result is escaped like any value.

{{ wp_size_format(bytes, decimals = 0) }}

A size in bytes as a readable size with unit, e.g. "2 KB", as returned by size_format(), as text. Returns '' if WordPress cannot format the size, e.g. a negative one.

{{ wp_size_format(attrs.fileSize, 1) }}
ParameterTypeDefaultDescription
bytesintrequiredSize in bytes.
decimalsint0Number of decimal places.

Returns string