This plugin returns a human readable filesize for a file residing on your server.
The file must be an absolute path.
{exp:ss_human_filesize}/uploads/documents/your_document.pdf{/exp:ss_human_filesize}
Will return something like
105 KB
The function calculates whether it should display KB, MB or GB.
Pretty simple but useful for showing users the size of downloads.
Hi George,
I think you may have been beaten to the punch on this one unfortunately.
Will definitely take a look at yours as well though. Can never have enough plugins I always say!
Plus yours is in an easy to find thread too! 😉
Thanks for sharing it with everyone.
Best wishes,
Mark
This plugin will return a human readable file size for a file without http:// or the domain (e.g. ‘/uploads/docs/yourfile.pdf’) and calculate the appropriate unit (KB, MB or GB) for you based on file size.
Filesizer lets you specify the unit and decimals and accounts for server_path in the upload preferences. So Filesizer has more features - had I seen it before posting I probably wouldn’t have bothered!
had I seen it before posting I probably wouldn’t have bothered!
I wish I’d kept shtum now 😉
Sorry George although in your defence (and partly mine if I may? 😉 ) it’s never a bad thing having more than one way of going about doing things. Your plugin will certainly stay in my mind if anyone ever asks about how to do this kind of thing and also you have learnt some more of the way ExpressionEngine works in creating a plugin so that can’t be a bad thing either can it?
Sorry again though.
Best wishes,
Mark
Is this plugin still supported? I’m trying to use this over Filesizer because I need a size based on files that exist outside of the EE uploads directory. I’ve had problems getting this plugin to even see the files on the server. One thing I noticed is that my server was injecting / for the slashes inside the path between the tags. So I inserted a str_replace to fix that, but still no dice. I have analyzed the path output a million different times and it looks correct. I just can’t seem to figure out what the problem is. Just checking to see if George Ornbo might take a look at this. Thanks!
The latest source is on Github http://github.com/shapeshed/human_filesize.ee_addon/tree/master, feel free to fork it or develop it further.
It is a pretty simple PHP function to be honest! Have you tried passing a manual path to the plugin? In your template hard code the file location to see if that works
{exp:ss_human_file_size}/path/to/yourfile/{/exp:ss_human_file_size}
Hope that helps.
Note that the Github version of this plugin causes my EE plugins page to blank out (white page, no content). When I remove the plugin from my server, the page returns as expected. I add it back in, and the plugins page blanks out again.
The original 1.0.0 version downloadable from this thread does not cause this problem. However it doesn’t work with absolute paths.
I’ve struck a problem that many people seem to get with file fields - tags and extra spaces can get added around the file path.
I’ve solved this by modifying the plugin so that it applies the strip_tags() and trim() functions to the path before attempting to calculate its size.
The new version of the plugin is attached.
Hi Craig,
Thanks for your fix.
I’ve merged this into the 1.1.1 release and also the 2.0.0 for EE2. I’ve also credited you as an author in the control panel settings and source code.
http://github.com/shapeshed/human_filesize.ee_addon/
If you click on downloads you’ll be able to download the different versions.
Cheers George
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.