1 of 3
1
Plugin Request: File Size Tag?
Posted: 28 November 2005 11:08 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  288
Joined  09-14-2004

This is based on this discussion.

Basically, I think it would be nice to be able to automatically append the file size of something you just uploaded through the EE interface. Can any one help? Is this possible? Details in the thread I linked.

 Signature 

{ say it once, say it twice, lealea says it’s nice } { host,  EE Podcast } { member, professionals network }

Profile
 
 
Posted: 28 November 2005 12:01 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15994
Joined  05-20-2002

Personally, I’d probably prefer the size be entered into a custom field- so I’d probably go at it by modifying the upload to grab the file size and insert it in a field for display purposes.  Which really wouldn’t be that hard aside from figuring out an interface that allows a painless way to map it to the proper field.  Extensions would probably make this doable with no hacking involved.

Just seems cleaner to me than grabbing the file size on the fly.

But yea- it would be a nifty plugin in whatever format!

 Signature 
Profile
 
 
Posted: 28 November 2005 02:16 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  288
Joined  09-14-2004

Yes! A custom field would be even better! It’s just that I know how to manually type in the file size, but clients… They are confused creatures, at times. wink Anything that’s automatic would be good.

 Signature 

{ say it once, say it twice, lealea says it’s nice } { host,  EE Podcast } { member, professionals network }

Profile
 
 
Posted: 28 November 2005 08:30 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Rank
Total Posts:  74
Joined  04-22-2002

I’m more interested in a {filesize} tag for downloads—photos, PDFs, whatever—a plugin that would auto-read a given fileon the server and display its size so the site user could consider whether to download it.  Parameters might control whether filesize is listed as KB, MB, whatever.  I realize there’s some pretty simple PHP one could stick into a template to do just this, but a plugin would give sitewide utility and be more useful to site design than (no slight intended, but merely by way of example!) Pirate Speak.  My guess is it would rank among the top ten plugins.

Profile
 
 
Posted: 28 November 2005 08:45 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  288
Joined  09-14-2004

Actually, that’s what I meant. grin Anything so that whoever is downloading knows how big the file actually is.

 Signature 

{ say it once, say it twice, lealea says it’s nice } { host,  EE Podcast } { member, professionals network }

Profile
 
 
Posted: 29 November 2005 09:27 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  168
Joined  07-22-2004

give me a few minutes and I’ll hook you up with what timj described.

edit: here you go smile

Sample code:
The file is {exp:filesizer filename=”{filename}” upload_pref=“1” units=“kb” decimals=“2”}Kb in size.

Please note:
Whatever is in {filename} it must be a valid filename located in the given upload preference lest bad things will happen.
You can only feed the filename=”” param with a filename as it is appended to the server_path of the given upload preference.
Also, make sure your upload preference’s server_path isnt relative.. cause that breaks the plugin..

:: andy

File Attachments
pi.filesizer.zip  (File Size: 2KB - Downloads: 750)
 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 29 November 2005 10:10 AM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2020
Joined  08-04-2002
ExpressionEngineer - 29 November 2005 02:27 PM

give me a few minutes and I’ll hook you up with what timj described.

Am interested also :-)

Profile
 
 
Posted: 29 November 2005 10:39 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  168
Joined  07-22-2004

Uhm.. I guess I’d better reply so everyone gets a ping from the forum module smile

File attached along with some notes in my original post above.

:: andy

 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 29 November 2005 05:23 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  288
Joined  09-14-2004

Thanks so much! Works like a charm. :-D

 Signature 

{ say it once, say it twice, lealea says it’s nice } { host,  EE Podcast } { member, professionals network }

Profile
 
 
Posted: 29 November 2005 05:24 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  288
Joined  09-14-2004

Oh, one more teeeeny request… Because I’m so demanding, heh… Is there a way to add a variable where it switches to MB after it’s past 1024 KB i.e. 1 MB? Thanks muchly!

 Signature 

{ say it once, say it twice, lealea says it’s nice } { host,  EE Podcast } { member, professionals network }

Profile
 
 
Posted: 29 November 2005 07:04 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Rank
Total Posts:  74
Joined  04-22-2002

Andy, I am impressed you turned this around so quickly.  Very cool.  I am not able to get it to work, however;  it reads zero.  Here’s my tag:

{exp:filesizer filename=”{title}.pdf” upload_pref=“3” units=“mb” decimals=“1”}

{title} refers to the name of the pdf, and I hope you can embed tags like this.  upload_pref is set to the number of my PDF upload directory.  Is this tag properly constructed?

I’ve rechecked my server_path info and it is correct.  Not to look a gift horse in the mouth, but the plugin might be more flexible if 1) it didn’t require an absolute server_pathname and/or 2) you could enter in the url as part of the filename or in a {path=} tag.  Maybe something to think about for v1.0.

Many thanks!

Profile
 
 
Posted: 29 November 2005 07:07 PM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  288
Joined  09-14-2004

Timj: I made {filename} into an actual custom field that I typed the file’s name in it. Perhaps with {title} it’s looking for the Title of your post, as opposed to the name of the PDF?

 Signature 

{ say it once, say it twice, lealea says it’s nice } { host,  EE Podcast } { member, professionals network }

Profile
 
 
Posted: 29 November 2005 07:09 PM   [ Ignore ]   [ # 12 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  26056
Joined  05-14-2004

lealea is absolutely correct.  You are best to rename that custom field to something other than {title} - if it is indeed a custom field?

 Signature 
Profile
MSG
 
 
Posted: 29 November 2005 07:23 PM   [ Ignore ]   [ # 13 ]  
Grad Student
Rank
Total Posts:  74
Joined  04-22-2002

Well, in this instance the {title} is the name of the file.  This is a special weblog I’ve created to archive and index these pdfs.

Profile
 
 
Posted: 29 November 2005 07:49 PM   [ Ignore ]   [ # 14 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2020
Joined  08-04-2002

Ehhh…thanks Andy!!!

Profile
 
 
Posted: 30 November 2005 01:07 AM   [ Ignore ]   [ # 15 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  168
Joined  07-22-2004

Sorry if the current functions doesn’t do it for you guys,
right now I don’t have time to move forward with this plugin, paid work has priority,
and I expect I’ll go back to the Keyword module before I update this plugin (when I get some spare time).

I’ve got a few ideas for updated functionality, but that’s pretty far into the future.

:: andy

 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 28 June 2007 01:22 AM   [ Ignore ]   [ # 16 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  168
Joined  07-22-2004

I’ve updated the plugin to 0.2 according to Ryan Masugas mod.

I’ve also put the upload_pref server path variable in the cache,
so that a page with 100 files (= 100 calls to the plugin)
will only fetch the server_path from the DB the first time,
the subsequent calls will fetch the server_path from the Session cache.

Enjoy!

File Attachments
pi.filesizer.zip  (File Size: 2KB - Downloads: 525)
 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
Posted: 28 June 2007 02:47 AM   [ Ignore ]   [ # 17 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1632
Joined  01-05-2007

Works great now Andy, thanks!

 Signature 

Steven Hambleton | Hambo Development

WE SPECIALISE IN WORKING WITH AGENCIES AND BUILDING LONG TERM DEVELOPMENT PARTNERSHIPS 
Profile
 
 
Posted: 28 June 2007 02:49 AM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  168
Joined  07-22-2004

You’re quite welcome Steven.

 Signature 

ExpressionEngineer - custom solutions for EE

I EE

Profile
 
 
   
1 of 3
1