Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
The question is, when you delete something from Umbraco's Media section in the back office, should that action also delete the file from the /media/ folder on the disk?
The simple and expected answer is "yes". But that's not what happens. At least not in all cases.
The media section forms a sort of 'catalog' of the images, files, and organizational structure of the media used on your site. The folder structure is purely organizational for display in the back office; the actual files are all stored in the /media directory on the server, followed by a unique identifier. This allows easy re-organization of the media section without altering the paths and urls to that media. It also allows for multiple files with the same name in the catalog without over-writing them (/media/1234/photo.jpg and /media/2054/photo.jpg don't collide).
It is important to note that files uploaded to the site using the 'upload' datatype property editor also appear on disk in the /media/xxxx/ directory but do not appear in the back office Media section catalog.
Uploaded items are typically for single-use, such as a job applicant's CV or a one-use marketing image. Items put directly into the back office Media section catalog are typically for re-use and/or for easy selection by content editors. This distinction will be important for our discussions below.
Reasons media files should not be deleted
Reasons media files should be deleted
Current behavior when deleting media items
An old solution was a tool from Tim Gaunt at The Site Doctor that would scan the Umbraco database and file system and offer to delete orphaned media files.
This could be implemented as part of the new Health Check feature?
The inconsistency of behavior bothers me. I would like to see warning dialog that gives users the option to delete an item from the back office Media section catalog and optionally to remove the file(s and folders) from disk, with a warning that deleted files can't be restored).
Adobe Lightroom has a similar concept of a catalog and actual files on disk. When deleting you are prompted with this dialog:
Delete the selected master photo from disk, or just remove it from Lightroom?
Delete moves the file to Finder's Trash and removes it from Lightroom.
[Delete from Disk] [Cancel] [Remove]
This might be a good starting point for Umbraco as well.
Or perhaps a Media Maintenance Dashboard would be helpful, especially for bulk operations.
A dashboard could also make it possible to have an insight into "Uploaded" items that are on disk but not otherwise visible in the back office.
And, a dashboard could let users quickly select items that are not referenced in content, templates, css, js, etc.
I don't suppose there is any way to look for requests and hits to a file on disk in the /media/ directory to alleviate the concern of potentially deleting a file that has inbound links even though it might not be used on the website itself. It would be great if possible, though.
Drag-n-Drop within the back office Media section catalog treeview would be ideal, since no urls will change as a result (which would be the case in the Content section and is often the primary reason for not allowing drag and drop in the treeview). Very easy for content editors to keep the media section organized.
Though strictly speaking this isn't part of the discussion on what should happen with regard to deleting media.
Great topic Doug! You've covered all the use-cases, which I complete agree.
The heart of the issue is property-editors, specifically in this case the "Upload" property-editor. There isn't a concept for them to be notified when a piece of content or media is being deleted, thus there can be no clean-up process for them.
At a technical level, I guess the answer is for Umbraco core APIs to trigger a deletion event that a property-editor can hook in to.
(I'm also thinking about those edge-cases where people have Archetypes with various Upload fields)
I really like the Lightroom prompt example, that would be a great UI prompt for the user.
Comment author was deleted
Thanks Doug for creating this, I recently had to research this myself and you did all the leg work :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted