Problem/Motivation
If you add an image via /media/add/image, you can click the "Remove" button after uploading a file, and the file you just uploaded is immediately deleted.
If you try to upload an image via the media library, you can click a "Remove" button for the item before you save it. However, when you do that, the file is not deleted right away. It is marked as temporary (there is pre-existing test coverage to confirm this), and therefore cleaned up at a later time by cron. This isn't necessary a major problem, but it's both inconsistent and a little more "lax", from a privacy standpoint, than the normal file field widget.
Steps to reproduce
- Add a media field to the article node type configured with the media library widget
- Create a new article
- Open the media library
- Upload a new image
- Click the 'Remove' button in the second step of the add form
- The media item is removed, the uploaded file however is still available on the server
Proposed resolution
Immediately delete a media item's associated file when pressing 'Remove' after uploading something in the media library.
Remaining tasks
Write a patchReview- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
When adding items to the media library, uploaded files associated with unsaved media items are immediately deleted when the media items are removed.