Skip to content

Twig Helpers

Filters

format_bytes

Formats a number of bytes into a human-readable string using ByteSizeMarkup.

Example:

# This assumes the file variable is a file entity object.
{{ file.getSize()|format_bytes }}

Functions

file_data_uri

Converts a file URL into a data URI using the File::getDataUri() helper.

Example:

# This assumes the file variable is a file entity object.
{{ <img src="file.getFileUri()|file_data_uri" alt="Inline source image" /> }}