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 Request: File Size Tag?

Development and Programming

ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer
  • added wings and pixie dust
  • fixed undefined notice (maybe..)

Please report back!

       
Daniel Walton's avatar
Daniel Walton
553 posts
17 years ago
Daniel Walton's avatar Daniel Walton

I’m quite partial, have to say…

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

Is it not true that these should be flipped?

// find the file and measure up..
        $file = (substr($filedir,-1, 1) == '/' ? $filedir : $filedir.'/').$filename;

        //    magical unicorns, now with wings and pixie dust
        $filename = basename($filename);
        $tmp = array_reverse(explode('.', $filename));
        $fileext = $tmp[0];

I was thinking that “find file and measure up” should be renamed “pixie dust” and then unicorns should come before pixie dust. I’ll try your latest, though. This has become quite the thread. Sort of…trippy.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

Hm.. don’t think they should be flipped, you see unicorns > pixies but just to confuse us when we come back to this thread in 15 months, I’ll upload another build here.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

The only reason I needed them flipped is due to how Mark Huot’s File extension outputs the content of its field, which is a whole path. If I use his extension to upload “masugadesign.vcf” (my vCard) to a file field, and put filesizer on it in the template, I get this error:

Error opening file: "/home/me/public_html/files/http://www.mysite.com/files/masugadesign.vcf"

But flipping those, so we get the basename first, I get the correct output, as seen in the attched pic.

And now, I think we’re done…at least for a few months. Thanks for all your help on this, Andy!

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

Funny thing, I could have sworn I flipped them in the 033 release, and typed the opposite in the post; you know, just for funsies..

In this release they are flipped for real though, not just in my head.

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

I had to guess what the file upload preference number was. I had set up more download folders originally but I consolidated them to just two.

EE reports my two folders as 1 and 2 but behind the scenes it has them as 2 and 4!

It would be very messy if I had 20 folders!!

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

Is it possible to have a sort of “virtual” folder set in the upload preferences to use in the plugin syntax?

More specifically, I have a set of folders with MP3 files in them. Every year we move to using a new folder with that year label. So we have /2006, /2007 and now /2008. Is it possible to set the upload folder as the base folder that those year folders sit in and then program the back end to look deeper according to the year?

My initial syntax (that did not work) looked like this:

<a href="http://mysite.com/podcast/audio/{entry_date">Download Audio</a> » {exp:filesizer filename="{entry_date format="%Y/%m.%d.%y.mp4"}" upload_pref="7" decimals="1" zero_decimals="no"} {fs:file_extension}: {fs:file_size}{fs:size_unit} {/exp:filesizer}

The path in EE to download the file does work. But the Filesizer breaks, even though the error code shows the path perfectly. It just returns the error instead of delivering the file size.

Any ideas on whether this is possible? I am trying to avoid having a whole bunch of folders listed in the file upload preference. And to avoid a lot of conditionals in the back-end switching syntax/folders based on the year of the entry.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

Hm.. good question, I’m in the middle of another thing right now, but I’ll have a look asap and see if I can find out what’s breaking it. In the meanwhile, would you mind posting the error message here? Dont forget to edit out any sensitive (account) details.

Thanks.

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

Here’s the error code:

Error opening file: “/path-to/htdocs/theaterchurch/subdomains/media/podcast/video/2007/12.09.07.mp4”

The actual file can be seen at http://media.theaterchurch.com/podcast/video/2007/12.09.07.mp4

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

By the way, I’m not really using EE to upload these files. I am using FTP. I am just trying to get EE to look at a base directory and then have filesizer look deeper within according to the entry_date variable. So it won’t matter that the path in EE’s upload prefs doesn’t go all the way to the directory where the files actually are because I am not using the upload feature to get them there.

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

Ok, I’ve looked into it, and I think it’s not working because you’re passing it a “folder/filename”. I want to give you the option to silence the error, but I don’t want to break how the plugin works for everyone else.

I can add a quickfix param called additional_path=”” where you can use {current_time format="%Y"} or whatever to make the paths a little less static, would that do you any good?

I’ll also add silence=”yes”, to mute the error message.

edit: wrote too fast, forgot to think twice.

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

Correct.

Yes, that would be quite nice to have a little custom version that functions the way I need it to! Is there any risk involved from a security standpoint, or is this merely an unorthodox approach that wouldn’t merit support for others?

Thanks so much!

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

ExpressionEngineer Thanks for all your help on this. I really need to get something rolling on this fairly quickly. Obviously, I don’t mean to be pushy. After all, your helping me out a ton and I love the elegance of your solution! But I would need that tweak before it will work for me.

If I need to look another direction, let me know so I can try to get a solution in place. If you think it will only be a little more time, I’d love to wait it out. I just need an update. 😊

Thanks!

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

Sorry about the delay. I’m working around the clock on multiple things right now and have very limited time to look at this (no time at all really), but I can give it a proper whirl after the weekend, or if anyone else want to download the code and mod it for you that’s perfectly fine with me.

Let me know if you need me to look at it after the weekend.

       
1 2 3 4

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.