Hi,
1. CFS uses the default WP media uploader, so I’m not 100% sure if it supports this feature. I’ve added a GitHub task to investigate further – https://github.com/mgibbs189/custom-field-suite/issues/82
2. Yes. First, set the field’s “Return Value” option to “Attachment ID”. Then, you can use something like this:
$attachment_id = $cfs->get('my_file_field');
$bytes = filesize(get_attached_file($attachment_id));
echo size_format($bytes);
Hi and thank you for the prompt answer.
Regarding 2.:
I need to output attachment url (for file download purpose) and I wish to also output file size. If I set the field’s “Return Value” option to “Attachment ID” then I could not get URL, right?
Thanks again!
You can get the URL from the attachment ID using the wp_get_attachment_url function.
http://codex.ww.wp.xz.cn/Function_Reference/wp_get_attachment_url
GREAT!
For the reference for non coders like me, I’ve just added this to code above:
&attachment_url = wp_get_attachment_url($attachment_id);
and output url:
echo &attachment_url;
everything works great now.
Regarding restricting file uploads to certain file types. I’m sure that feature can be added, Attachments plugin from Jonathan Christopher support restricting file uploads to certain file types and works with WP 3.5
Regarding restricting file uploads to certain file types. I’m sure that feature can be added, Attachments plugin from Jonathan Christopher support restricting file uploads to certain file types and works with WP 3.5
Hey, I just spoke with Jonathan. It appears as though you can restrict uploads by category (audio, video, application), but not necessarily by specific file extension (zip, pdf).
I’ll post any further updates into the GitHub task.
Matt