We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: SS Human Filesize

Development and Programming

George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

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.

Download the latest version | Documentation

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

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

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

Arggh! Not sure how I missed that!

This plugin keeps it simple anyway!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
This plugin keeps it simple anyway!

Absolutely and has gone into my mental list of plugins so if anyone needs this type of functionality I will surely fire them in your direction 😉

Thanks again for releasing this for everyone, very kind of you.

Best wishes,

Mark

       
stinhambo's avatar
stinhambo
1,268 posts
16 years ago
stinhambo's avatar stinhambo

Are there any differences between the two?

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

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!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
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

       
davidrussell's avatar
davidrussell
102 posts
16 years ago
davidrussell's avatar davidrussell

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!

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

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.

       
davidrussell's avatar
davidrussell
102 posts
16 years ago
davidrussell's avatar davidrussell

Thanks, George. I worked it out. No doubt that slashes to entities issue was causing me trouble. I just forgot to pass that “processed” string down into the output. Works like a champ for me now.

       
fogcity's avatar
fogcity
260 posts
16 years ago
fogcity's avatar fogcity

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.

       
Craig Allen's avatar
Craig Allen
135 posts
15 years ago
Craig Allen's avatar Craig Allen

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.

       
George Ornbo's avatar
George Ornbo
272 posts
15 years ago
George Ornbo's avatar George Ornbo

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

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.