Skip to content
This repository has been archived by the owner on Aug 24, 2018. It is now read-only.

The file types upload are not restricted according to the Widget type #128

Open
miina opened this issue May 4, 2017 · 10 comments
Open

The file types upload are not restricted according to the Widget type #128

miina opened this issue May 4, 2017 · 10 comments
Labels

Comments

@miina
Copy link

miina commented May 4, 2017

It's possible to set an image to video/audio widget etc. Will be displayed as links / broken image.
screen shot 2017-05-04 at 3 48 19 pm

@westonruter
Copy link
Contributor

To clarify: this is during the upload flow. The media browser does successfully restrict the file types, but the upload UI currently is not.

@westonruter westonruter added the bug label May 4, 2017
@westonruter westonruter changed the title The file types are not restricted according to the Widget type The file types upload are not restricted according to the Widget type May 4, 2017
@melchoyce
Copy link
Contributor

Is this fixable?

@timmyc
Copy link
Contributor

timmyc commented May 4, 2017

I suppose we could do some extension testing in the selection callback to ensure we have a valid extension per the widget. Kind of feels like the media modal should prevent this though.

@westonruter
Copy link
Contributor

There should be a parameter to pass to the upload state to restrict the type.

@westonruter
Copy link
Contributor

Hummm. This seems like it may actually be a core bug. For example, if you go into edit a post, and you open the media modal to select a featured image. From this screen, you can go to upload a video and then select it. That shouldn't be possible.

@Presskopp
Copy link

Presskopp commented May 4, 2017

FYI, there's a related ticket:
https://core.trac.wordpress.org/ticket/39625

@westonruter
Copy link
Contributor

I can see the full list of MIME types when I look at wp.media.frame.uploader.uploader.uploader.settings.filters.mime_types. I'm not sure how to properly override it, however.

@westonruter
Copy link
Contributor

I'm not the only one to ask the question: http://stackoverflow.com/questions/38400352/plupload-change-mime-type-filter-after-init

@westonruter
Copy link
Contributor

Looks like there is a bug in Plupload affecting the ability to change the file filter after init: moxiecode/plupload#1339

@joemcgill
Copy link
Contributor

I've been digging into this issue a bit but haven't had time to code a solution yet. However, thought it might help to leave some initial thoughts.

All of the supported mime types get passed to plupload via _wpPluploadSettings when the Uploader is created. As far as I can tell, each frame gets a unique Plupload instance, so we could potentially reach in and change the supported mime types when the uploader is added to the view, but that seems dirty.

My current idea would be to try extending the wp.media.controller.Library during state creation so you could add a mime type check on the upload callback that happens here.

Regardless, I don't see this as a blocker for merge, since the same issue exists currently any time media frame is created.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants