Display the size of a file in MegaBytes in a files section

How can I display the size of a file in MB in a filesection. I use the info property and the query language like that info: "{{ file.size }}" but it returns the size of the file in bytes and not in MB.

You can create a custom file method that converts the size in bytes to your desired unit, then use this method instead.

1 Like

ok, thank you.
Just one question for a better understanding.
Why is the size method not shown? And where does it come from?

Because it is inherited from the F class; the reference is mainly auto-generated through the PHP Reflection class.

Ah ok.
Also I found that the F class has the function
nicesize
which does exactly what I wanted.

thanks :+1:

I would have suggested niceSize() but you said you wanted MB… :woman_shrugging:

1 Like