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

Sk8erPeter’s picture

Title: PLUpload: List of allowed file-types are never set because plupload_element_pre_render is never called » Plupload: List of allowed file-types are never set because plupload_element_pre_render is never called
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new41.85 KB

Cool, 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:

Media multiselect unsupported file type

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!

fangel’s picture

The 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...

Sk8erPeter’s picture

Oh, I think you're right, thanks. :) Maybe I should suggest its developer some alternatives, but this will happen on another day. :)

ParisLiakos’s picture

Assigned: Unassigned » ParisLiakos

i ll definitely check and commit this, but might be in next week

slashrsm’s picture

StatusFileSize
new1.48 KB

Looks good. I fixed some coding standard things...

ParisLiakos’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Kazanir’s picture

Status: Closed (fixed) » Active

I have the latest dev of both File Entity/Media and PLUpload but this patch doesn't appear to have solved the problem for me. :(

Sk8erPeter’s picture

@Kazanir: could you be more specific?

Kazanir’s picture

I 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.

fangel’s picture

How 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:

  • What are you trying to do?
  • How do you attempt to do it?
  • What are you expecting to happen?
  • And what actually happens?
Sk8erPeter’s picture

@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?

Kazanir’s picture

I'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

ParisLiakos’s picture

Assigned: ParisLiakos » Unassigned
Status: Active » Closed (fixed)

I am confused. can you open a new support request and then link it here? lets leave this issue to die