Discussion - should deleted media be removed from disk
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.
Media section concepts
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
The file might be used in a template, css, or js and that isn't known to the content editors who could delete an important file
The file might be have direct in-bound links from an email campaign or other use that is not part of the content of the site itself, and those links would break if the file were deleted
The recycle bin in the back office Media section only stores the database entries rather than the actual files; if the files were deleted there would be no way to restore them
Reasons media files should be deleted
The natural user expectation is that files on disk are also deleted when deleting media nodes from the back office Media section catalog, or when clicking the 'Remove file(s)' link on a specific back office Media section catalog node
Current behavior when deleting media items
Creating back office Media catalog nodes
When a file is added to the back office Media section catalog, the original file is place on disk in /media/xxxx/original.filename.extension
If the original file is an image, a .jpg thumbnail file is also created and placed in the same folder on disk, along side the original file
If the original file is an image but not a jpg file, an additional thumbnail image is created of the same format an extension (especially handy for transparent .png files to have a transparent .png thumbnail)
Deleting back office Media catalog nodes
When deleting the entire node from the back office Media section catalog using the 'Delete' action menu item, the node is put into the Media section's Recycle Bin and can be restored by the user. No files are deleted from the file system
When deleting a node from the back office Media section's Recycle Bin (or Emptying the entire recycle bin), the files are deleted from disk, including the numbered folder that contained the original image and thumbnails
Deleting the file associated with a back office Media catalog node
Selecting a back office Media catalog node and clicking the Remove file(s) link deletes the file from the file system as soon as the content editor clicks the Save button in the back office.
However, any thumbnail files remain on disk (if the deleted file were an image). If the deleted file were not an image and thus no thumbnail files exist, an empty folder remains at /media/xxxx/
There is no way for users to undo the file deletion and restore the file
Deleting files on disk placed their by an Upload data type property editor
There is no way for content editors to do this from the back office. "Uploaded" files are not visible from the back office
What are your ideas? What's needed, if anything, to improve media reorganization and deletion?
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.
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.
Discussion - should deleted media be removed from disk
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.
Media section concepts
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
What are your ideas? What's needed, if anything, to improve media reorganization and deletion?
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.
http://thesitedoctor.co.uk/blog/clean-out-unused-media-items-from-umbraco-media-folder/
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.
Cheers,
- Lee
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...