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

Editor: Make mime type config less confusing #10709

Merged
merged 58 commits into from
Mar 10, 2022
Merged

Conversation

spacedmonkey
Copy link
Contributor

@spacedmonkey spacedmonkey commented Feb 24, 2022

Context

Summary

Make the handling of mime types and file extensions much simpler, by scaling back. This scaling back includes.

  • Remove the following properties from the config object.
    • allowedFileTypes
    • allowedImageFileTypes
    • allowedImageMimeTypes
    • allowedAudioFileTypes
    • allowedAudioMimeTypes
  • Remove methods from type class.
    • get_allowed_file_types
    • get_allowed_image_mime_types
    • get_allowed_audio_mime_types
  • Remove the filter web_stories_allowed_image_mime_types

Make get_allowed_mime_types a single point of truth for all mime types that are handled by the editor / dashboard.
Do not add image/svg to image types by a new key vector key. This means image mime should all be considered web safe.

Relevant Technical Choices

Now all mime types are checked against if WordPress can upload them. That means that aacs are removed, because multisite can not handle this file type. There is a unit test to prove this and a skipped test.

There are some hardcoded mime type mapping, as these mime types are return the wrong file extensions or no file extension at all. This can not avoided sadly.

Handling of file extensions is now done in javascript and passing in file extensions to the config object.

To-do

User-facing changes

Testing Instructions

  • This is a non-user-facing change and requires no QA

This PR can be tested by following these steps:

Reviews

Does this PR have a security-related impact?

Does this PR change what data or activity we track or use?

Does this PR have a legal-related impact?

Checklist

  • This PR addresses an existing issue and I have linked this PR to it in ZenHub
  • I have tested this code to the best of my abilities
  • I have verified accessibility to the best of my abilities (docs)
  • I have verified i18n and l10n (translation, right-to-left layout) to the best of my abilities
  • This code is covered by automated tests (unit, integration, and/or e2e) to verify it works as intended (docs)
  • I have added documentation where necessary
  • I have added a matching Type: XYZ label to the PR

Fixes #10592

@spacedmonkey
Copy link
Contributor Author

I have made some tweaks to the Type class, to remove unneeded methods. I would strongly consider removing the get_allowed_image_mime_types method and web_stories_allowed_image_mime_types as they are no longer really needed. Thoughts @swissspidy ?

@swissspidy
Copy link
Collaborator

Yes we should remove the unused code 👍

@spacedmonkey spacedmonkey changed the title Remove lots of mime properties. Editor: Make mime type config less confusing Feb 28, 2022
@spacedmonkey spacedmonkey self-assigned this Feb 28, 2022
@spacedmonkey spacedmonkey added P2 Should do soon Pod: WP Type: Code Quality Things that need a refactor, rewrite or just some good old developer ❤️ labels Feb 28, 2022
@spacedmonkey spacedmonkey requested a review from timarney March 3, 2022 11:55
@spacedmonkey spacedmonkey requested a review from swissspidy March 4, 2022 16:38
@spacedmonkey
Copy link
Contributor Author

What is happening with this pr?

@swissspidy
Copy link
Collaborator

There are some karma test failures after merging main.

Also, fixed the spaces vs tabs issue for you.

@spacedmonkey
Copy link
Contributor Author

Karma tests are now passing. I missed one last place that had not been changed.

@spacedmonkey spacedmonkey requested a review from swissspidy March 10, 2022 13:48
@swissspidy swissspidy merged commit ea681b2 into main Mar 10, 2022
@swissspidy swissspidy deleted the try/mime-type-tidy-up branch March 10, 2022 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Should do soon Type: Code Quality Things that need a refactor, rewrite or just some good old developer ❤️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor: Make mime type config less confusing
4 participants