A Twig extension to convert filesize to human readable string.
composer require oskarstark/readable-filesize-extension
# config/services.yaml
services:
OskarStark\Twig\ReadableFilesizeExtension:
tags: ['twig.extension']
// file.size = 1024
{{ file.size|readable_filesize() }} # prints '1 KB'
{{ file.size|readable_filesize(2) }} # prints '1.00 KB'