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.
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!
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. Anything that’s automatic would be good.
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.
give me a few minutes and I’ll hook you up with what timj described.
edit: here you go
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..
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!
{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.
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?
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.
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.