-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Allow file uploads using drag and drop & add placeholder #5462
Comments
Glad this is on the radar. The lack of a "Files" block resulted a few moments of unsuccessfully attempting to insert a file. At first I thought perhaps the "Images" block might play double-duty as a general media upload, but it doesn't allow alternate formats. I eventually opened the Media Library in a separate window to upload a PDF, copied the URL, and then added it as a hyperlink back in the post. This was very cumbersome. If there is an alternate way to do this currently, it wasn't obvious. |
I will be working on implementing this feature. Here is what I plan to do:
Let me know if there are any concerns or suggestions about this approach. |
That approach sounds great, thank you @mirka! |
@mirka, the plan looks good. The idea of allowing the user to upload anything and then let them transform the block into a specific one is especially powerful. If the user specifics a URL, will we download the file or link to it/embed using the external URL? Do you think we can somehow communicate with Gutenberg that are the allowed filetypes to avoid errors after upload (I would have to upload a 2GB log file to be rejected)? Can we do it? Are there any downsides? |
I‘m thinking of making the text link part a normal link, and the download button an HTML5 download link. The @nb:
For now I‘m not going to sideload specified URLs, to keep the behavior consistent with audio/video blocks. This means that:
Good point. I looked into this and found that a pre-check and error-messaging enhancement is in the works (#4203). I think we could add a mime type check in there using get_allowed_mime_types(). I’ll post a separate issue for that. As for downsides... I feel like it would be much easier for everyone if the REST API in Core could handle it better, like check the headers for Content-Type and Content-Length first and return an error without waiting for the binary transfer to complete. But I guess life is not that easy! |
WordPress supports a number of image, audio and video filetypes. We have media placeholders for each of those, and you can drag and drop them to upload.
WordPress also supports a number of filetypes that aren't media, such as pdf, doc, and others. See full list here: https://codex.wordpress.org/Uploading_Files
You should be allowed to upload and insert these files using drag and drop from the desktop. For example if you drag and drop
Schedule.pdf
into the editor, you should get a file block, like this:From that, you could copy the link and paste it over text if you like, to create a normal link:
There would also be a placeholder block for files:
The text was updated successfully, but these errors were encountered: