digitalpoint
Well-known member
- Affected version
- 2.2.13
I'm aware that this is pretty nitpicky, but XenForo is using a base 1024 system for filesystem sizes and then incorrectly labeling them as KB, MB, GB, TB, etc (those are base 1000 labels) in
See: https://en.wikipedia.org/wiki/Megabyte
The numbering system XenForo uses is KiB, MiB, GiB, TiB, etc.
Not a huge deal in itself as it's mostly cosmetic, but it starts to get weird when you are comparing things like attachment sizes in XenForo to a system where they are labeled correctly and the underlying numbers don't match. You end up needing to do some kludgy stuff in templates to "undo" XenForo's "incorrectness" so things match up:
XF\Language.php
.See: https://en.wikipedia.org/wiki/Megabyte
The numbering system XenForo uses is KiB, MiB, GiB, TiB, etc.
Not a huge deal in itself as it's mostly cosmetic, but it starts to get weird when you are comparing things like attachment sizes in XenForo to a system where they are labeled correctly and the underlying numbers don't match. You end up needing to do some kludgy stuff in templates to "undo" XenForo's "incorrectness" so things match up:
Code:
<xf:macro name="file_size" arg-size="!"><xf:trim>
<xf:comment>Kind of dumb, but XenForo is using base 1024 and labeling it as if it's base 1000, so in order for it to match Cloudflare's stats (they are doing it correctly), we need to adjust what XenForo presents.</xf:comment>
<xf:if is="$size >= 1024"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
<xf:if is="$size >= 1048576"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
<xf:if is="$size >= 1073741824"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
<xf:if is="$size >= 1099511627776"><xf:set var="$size" value="{{ $size * 1.024}}" /></xf:if>
{{ file_size($size) }}
</xf:trim></xf:macro>