This works beautifully, except for when the filefield is limited to only one item. I'm presuming that plupload can still handle single file uploads nicely, and will apply all it's benefits (chunking, progress etc.) to a single item upload. I'm also presuming that this issue can be resolved here, rather than in the filefield sources module.
Thanks
Simon
Comments
Comment #1
atlea commentedHum. I will have to look into limiting the number or files. I'll add this to the todo!
Comment #2
burgs commentedAtlea, you are a legend. It looks like the plupload team themselves don't really have an elegant, documented solution for this, so that might be a small issue. Let me know where I can help.
Comment #3
osmanI believe I have a solution. Please review and test it.
Edit: There are some proper labeling issues, and typos, etc. But the functionality should be ready for reviewing.
Comment #4
adam_b commentedWorks well for me - many thanks :)
Comment #5
atlea commentedNice one! I'll try to have a new dev that includes this functionallity over the weekend. :)
Comment #6
Tsubo commentedHas patch #3 been committed yet?
Comment #7
trebol commentedI cant apply the patch by atlea, because the code of the patch its different of the code i see in my module. i got the last version installed, and this option is not added.
Any valid script to enable single file upload?
Comment #8
antipode commentedgreat - I tried something myself but was not aware of the $element['#attached']['js'][].
however - I still get the option to add more files when uploading. I thought this patch will allow only for 1 file to select and upload.
Comment #9
osmanHere is an updated patch.
If cardinality is set to "1", Plupload is forced to select only one file at a time in "file select" dialog windows by adding
multi_selection: FALSEandmultiple_queues: FALSEsettings to plupload object.If cardinality is set to anything but unlimited; number of the files in the queue is checked on "
QueueChanged" event.Files exceeding the limit are removed from the queue instantly. Meanwhile, Add files link/button is kept hidden when the number of the files in the queue matches the (cardinality) limit.
I tested this with different cardinality settings. But please do test it yourselves as well.
Comment #10
osmanForgot to mention; with this patch cardinality value is passed to plupload object as a setting. So it would be available at all times.
Later it is used in plupload.js as
pluploadSettings.cardinalityin QueueChanged event.Comment #11
muschpusch commentedok this patch is awesome because of two reasons:
- single file upload (my usecase i use plupload because of chunking large files)
- cardinality is checked before uploading on plupload side
Comment #12
muschpusch commentedok just some little adjustments to the label
Comment #13
atlea commentedPatch seems to work nicely. I have added it to the dev-version.