-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: Make mime type config less confusing #10592
Comments
I wonder if we should have one object with all this data. Something like this
So to get
There is also a difference between allow images types and list images that can be uploaded. One is used for allow images for posters. How would be best denote that? |
Including file types in there is redundant and makes it harder to maintain for us and everyone trying to build an editor. We can operate with just mime types and then use
The suggestion above is to rename the existing fields to make that more clear. |
Do we even need
So to get
|
Precisely. That's what I meant in the ticket description by saying we can make it obsolete. |
There might be a problem with passing down mime types and getting an extension array in the case of |
Thanks for flagging that. Agreed that we need to keep that in mind. As far as I know we only use the file extensions to display user-facing messages like If the user-facing message now says |
There is a similar argument for mp4/m4v files as well. Also what if developers add a custom file type, like videopress or a new file format. It may not be part of the mine type package. |
I'm not concerned about invalid mime types, we don't really support that. |
My orignal suggestion #10592 (comment) would handle this issue. As you can see in my sudo code shows, that structure can support multiple file extensions with the same mime types. |
Not catering for mime types with multiple corresponding file extensions is fine, because file extension info is only used for error messages. Again, I want us to avoid having to pass file extensions via config. It's redundant. So let's try it first without. If it doesn't work for some reason we can always revisit. And something like |
I have a POC PR up here #10709. I noticed a problem. The Take this example. audio/mpeg, returns mpga, not mp3 as expected. audio/acc returns null and not acc file. This is an issue with the mimetype library being used. This will have to be fixed or replaces. Can you advice @swissspidy |
It seems to work as expected, although it's definitely confusing at first. This is related to @ayushnirwal's comment above.
The mime package doesn't offer a way to get all of them, see broofa/mime#254
It's not a huge deal because again, this is only used for error messages. To make it less confusing it should be fine to have a hardcoded list of mime types for these cases See #10718 for my suggestion. |
Task Description
We currently pass this list of mime/file types to the editor:
web-stories-wp/includes/Admin/Editor.php
Lines 363 to 369 in f130e0c
As we are working on some documentation on using the decoupled story editor, it became more obvious how confusing this config is.
allowedMimeTypes
: map of allowed mime types for actual story elements. For example,allowedMimeTypes.image
might containimage/svg+xml
or something to say that you can drop SVGs on the canvasallowedImageMimeTypes
: this is used for places in the design/document tab where you can upload images (video poster, story poster, publisher logo). For example, here we would never want to allow uploading SVGs. Hence this separate config.allowedAudioMimeTypes
: similarly, this is used for when you want to add background audio to a page.In addition to that,
allowedFileTypes
is just a simple array of file types so that in the editor we can say “You are only allowed to upload jpeg, png, gif” etc. We can just get rid of this and usegetExtensionFromMimeType
from themedia
package instead.allowedTranscodableMimeTypes
is really pointless too, which is why I opened #10591 for that already.To-do
allowedMimeTypes
to somehting more obvious, like for exampleallowedElementMimeTypes
allowedImageMimeTypes
andallowedAudioMimeTypes
to something more obvious tooallowedFileTypes
obsolete by assembling that on-the-fly in the editor instead, usinggetExtensionFromMimeType
The text was updated successfully, but these errors were encountered: