Skip to content

Conversation

@jsma
Copy link
Contributor

@jsma jsma commented Dec 28, 2025

Previously the FileInput widget allowed all file types, which meant the user could select any file and then only find out it's not accepted after uploading. This ensures the FileInput only accepts the listed file extensions or in the absence of file extensions, restricts to audio/video files as appropriate.

While https://github.com/torchbox/wagtailmedia/pull/140/files handled server side validation, this complements that work by restricting the file types on the client side.

Previously the `FileInput` widget allowed all file types, which meant the user could select *any* file and then only find out it's not accepted after uploading.
This ensures the `FileInput` only accepts the listed file extensions _or_ in the absence of file extensions, restricts to audio/video files as appropriate.
@jsma
Copy link
Contributor Author

jsma commented Dec 28, 2025

Looks like the Python 3.9 tests failed because of the union operator in type hints. These didn't fail locally for me when running tox. I see #271 is open which would remove Python 3.9 support which is already EOL. Happy to rebase this once that PR is merged.

"""Returns the specified extensions in a format usable in the `accept=""` attribute of a `FileInput` widget.
This assumes the list of extensions are the bare extensions e.g., `["mp4", "webm"]` and prefixes each extension with
a ".".
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants