Hi,
I'm working on a multiselect widget for Media, and was informed that there was a problem in how the PLUpload upload-widget in the Media Browser handled the list of allowed file extensions was wrong. It allowed all file-extentions to be added to the widget, and only after the upload was complete did it show an error. For a reference see #1859654: No images get uploaded when selecting one or more unsupported file types too.
So I started looking into how you told PLUpload which file-extensions to allow. The plupload-module already handles this correctly: In their plupload_element_pre_render function, they add some JS settings that in turn gets sent to the PLUpload library.
BUT, the form generated by file_entity_add_upload_multiple never called plupload_element_pre_render. This is because it already supplies it's own list of pre_render functions - one of which (file_entity_upload_validators_pre_render) even adds the upload-help text informing the user that only some file-extensions are allowed.
So I've created a patch that simply looks for the pre_render function "file_entity_upload_validators_pre_render" and replaces it with "plupload_element_pre_render" in the file_entity_add_upload_multiple-form. If the File Entity pre-render isn't there, it just adds the PLUpload one.
Kind Regards
Morten
Comments
Comment #1
Sk8erPeter commentedCool, thanks! I just tried it, and after applying this patch, an alert() window is popped up as many times as many unsupported files are selected.
Here is an example screenshot using media_multiselect module:
By the way, the one-by-one alert() is a really ugly solution, but I didn't inspect which module causes this behavior instead of a nice jQuery UI Dialog error message, BUT it's OK as a temporary (?) solution.
Thanks again!
Comment #2
fangel commentedThe alert-box comes from the PLUpload javascript library, I believe. The offending line seems to be this: https://github.com/moxiecode/plupload/blob/master/src/jquery.plupload.qu...
Comment #3
Sk8erPeter commentedOh, I think you're right, thanks. :) Maybe I should suggest its developer some alternatives, but this will happen on another day. :)
Comment #4
ParisLiakos commentedi ll definitely check and commit this, but might be in next week
Comment #5
slashrsm commentedLooks good. I fixed some coding standard things...
Comment #6
ParisLiakos commentedthanks, patch works indeed.
commited http://drupalcode.org/project/file_entity.git/commit/d6ccbd2
Comment #8
Kazanir commentedI have the latest dev of both File Entity/Media and PLUpload but this patch doesn't appear to have solved the problem for me. :(
Comment #9
Sk8erPeter commented@Kazanir: could you be more specific?
Comment #10
Kazanir commentedI went and investigated. I am running the latest dev of File Entity, Media, Plupload, and the 7.x-1.x of Multiform. When going to the Media Browser and adding a file, I don't get the plupload widget at all and when going to sitebase/file/add I get the multi-upload form but it doesn't have the correct set of file extensions. The missing widget in the Media Browser makes me think something else is wrong, but I have no idea what it could be. I'll keep digging though.
Comment #11
fangel commentedHow does it not appear to solve the problem? If anyone is to help try figure out why it doesn't work for you, while it worked for everyone else that tested this patch, we might need slightly more information.
So:
Comment #12
Sk8erPeter commented@Kazanir : adding to fangel's questions, you should also inspect the browser's console (F12 or Ctrl+Shift+I) whether there are JavaScript extensions, and you should turn on PHP error displaying until debugging, watch dblog, post a screenshot, etc... You didn't share too much information, so we don't know how to help.
Currently, it seems like it's an individual problem.
Have you also tested it on another Drupal installation?
Comment #13
Kazanir commentedI'm pretty sure I answered all of fangel's questions in my original posts:
- I'm trying to upload files using the plupload widget in a 7.x-2.x Media/File Entity install
- I'm attempting to do it via the file/add page
- I'm expecting the set of file extensions to be the set which is defined in the usual configuration spot
- The above doesn't happen and those files are not allowed
I appreciate that it seems like an individual problem but I don't really know where ELSE to look to debug things. There are no obvious errors and the form is being processed by plupload, and I don't have any other modules installed/on that would be interfering. Like I said I will keep digging and try it on a test site
Comment #14
ParisLiakos commentedI am confused. can you open a new support request and then link it here? lets leave this issue to die