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

Media file upload component #721

Merged
merged 6 commits into from
Mar 26, 2024
Merged

Media file upload component #721

merged 6 commits into from
Mar 26, 2024

Conversation

paulrobertlloyd
Copy link
Collaborator

@paulrobertlloyd paulrobertlloyd commented Mar 26, 2024

Partially fixes #538, #539 and #540.

Adds a fileInput component, that progressively enhances an <input type="text"> to be populated from the upload from an injected <input type="file">. After clicking the file selector and choosing a file, a fetch request is initiated that uploads the chosen file and returns the URL from the media endpoint.

Screenshot of file upload component.

Possibly a number of ways this could be improved, but I think this is a good first pass at making uploading images inline easier, certainly easier than going to the separate file upload page and copy and pasting an uploaded file URL.

Accessibility

Given restrictions around initiating a file picker programmatically, and without universal support for window.showOpenFilePicker(), am using a <label> styled as a <button> which is used to trigger the hidden <input type="file">. The label has been given a button role, added to the tabindex, and given the behaviours of a button so that it can be triggered using a keyboard.

Have tested using VoiceOver, but doubtless there are untold issues in other user agents. However, this seems like the most reasonable means of creating a button like control that can initiate the file picker. Open to other ideas on how this can be achieved.

@paulrobertlloyd paulrobertlloyd added enhancement New feature or request frontend plugin-post-type Post type plug-in labels Mar 26, 2024
@paulrobertlloyd paulrobertlloyd force-pushed the media-file-upload branch 2 times, most recently from 7c7b7ed to 9b098c5 Compare March 26, 2024 19:41
@paulrobertlloyd paulrobertlloyd marked this pull request as ready for review March 26, 2024 19:46
@paulrobertlloyd paulrobertlloyd merged commit db0ba5b into main Mar 26, 2024
1 check passed
@paulrobertlloyd paulrobertlloyd deleted the media-file-upload branch March 26, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend plugin-post-type Post type plug-in
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Posts endpoint: 📷 Create/update photo post type
1 participant