Skip to content
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

Rethink allowedType parameter in media-upload functions/components #7155

Closed
mirka opened this issue Jun 5, 2018 · 1 comment
Closed

Rethink allowedType parameter in media-upload functions/components #7155

mirka opened this issue Jun 5, 2018 · 1 comment
Labels
[Feature] Media Anything that impacts the experience of managing media [Type] Question Questions about the design or development of the editor.

Comments

@mirka
Copy link
Member

mirka commented Jun 5, 2018

I'm proposing two changes to the allowedType parameter used in the functions/components related to media uploading:

  1. Rename allowedType to accept
  2. Mimic the syntax rules for the accept attribute in an <input type="file">

I think this would result in less confusion in our codebase, and more flexibility/clarity for third-parties who are going to use these components.

Context

As we expand the scope of file uploads to filetypes beyond image/audio/video, I'm finding some problems with the allowedType parameter as it stands.

  1. The name sort of conflicts with WP's get_allowed_mime_types(), which is what we're planning to use for checking allowed types before uploading (Check allowed mime types before uploading media #6968).

    Note that the WP-side allowed_mime_types is the list of all types that the current WP user can upload, which is dependent on the site. In contrast, Gutenberg-side allowedType is being used for restricting a component to only accept a certain type, like "image" for Image blocks.

    For example, an SVG file would pass a Gutenberg-side allowedType="image", but it might be rejected against the WP-side allowed_mime_types if SVGs are not allowed. In any case, they each serve a different purpose and warrant different behaviors/errors when rejected, so we can't merge these two checks together. We should rename our allowedType so it won't be confused with the WP-side allowed_mime_types.

  2. The syntax to be used for allowedTypes is not immediately apparent. Since its purpose is very similar to the accept attribute in an <input type="file">, we could just rename allowedTypes to accept and mimic that syntax.

Relevant functions/components

@mirka mirka mentioned this issue Jun 5, 2018
11 tasks
@mtias mtias added [Type] Question Questions about the design or development of the editor. [Feature] Media Anything that impacts the experience of managing media labels Jul 19, 2018
@nerrad
Copy link
Contributor

nerrad commented May 26, 2019

I'm going to make the assumption that since this hasn't surfaced as a problem in pulls/issues since this was created (after performing a search), that this is not something that will get changed.

Note: in #9707 there was work changing this attribute from allowedType (or type in some cases) to allowedTypes.

This can be reopened or a new issue created if additional reasons arise for the naming.

@nerrad nerrad closed this as completed May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Media Anything that impacts the experience of managing media [Type] Question Questions about the design or development of the editor.
Projects
None yet
Development

No branches or pull requests

3 participants