Customizing SMF > SMF Coding Discussion

Show Attachments as KB, MB, GB ??

(1/3) > >>

SMF only shows attachment sizes as KB only there there a way to show them as MB and GB?? I have big files on my forum and people dont know what all the numbers are so this would be handy to have it show as MB,GB

In Display.php
Search for:

--- Code: --- 'size' => round($attachment['filesize'] / 1024, 2) . ' ' . $txt['smf211'],
--- End code ---
Replace with:

--- Code: --- 'size' => $attachment['filesize']>1048576 ? round($attachment['filesize']/1048576,2) . ' MB' : ($attachment['filesize']>1024 ? round($attachment['filesize']/1024,2) . ' KB' : $attachment['filesize'] . ' B'),
--- End code ---

That works great thank you for your time  

Ok so I know this is VERY old, however this is what I am needing to use on my forum.

However the above code does not work correctly and does not show the correct size in MB.

In what way is it "not working correctly"? Is it changing what's displayed, but not showing the expected numbers? Is it not having any effect at all? Is it showing MB and you want MiB? In that case, use 1000000 and 1000 for MiB and kiB instead of 1048576 and 1024.


[0] Message Index

[#] Next page

Go to full version