|taille_en_octets

  • New in : SPIP 1.4

The |taille_en_octets filter (meaning "size in bytes" in French) converts a number of bytes (25678906) into a more explicit character string ("24.4 MB").

Example within a DOCUMENTS loop:

#TITRE - #TYPE_DOCUMENT[  - (#TAILLE|taille_en_octets)])

will display "My document - JPEG - 82.6 KB"

By default, the filter returns sizes with the binary prefixes:

  • 1024 bytes = 1 kibibyte
  • 1024 kibibytes = 1 mebibyte

Etc.

It is possible to pass a parameter indicating the system you want to use: BI for binary prefixes (default), or SI for international system prefixes.

Thus [(#VAL{25678906}|size_in_bytes{SI})] will return 25.7 MB.

Note that the available prefixes go up to Gibi and Giga but no further (the most common file sizes on a website). The number of decimal places displayed is 0 if there is no prefix, 1 for Kibi, Kilo, Mega and Mebi, and 2 for Giga and Gibi.

Prior to SPIP 4.2, calculations were performed using the binary system, but displayed in international units.

Author Mark Published : Updated : 15/09/25

Translations : English, français, Português