Filesystem media is not deleted when deleting Media Library items

  • Out-of-the-box, Sitecore XP does not support moving, renaming, and deleting file system media associated with Media Library itemsIt is considered potentially dangerous because the file cannot be restored in case of an error. For example, a user might not know if the file to be deleted is used elsewhere on the website.

  • As a solution, consider one of the following options:

    • Change the approach for storing media items (recommended). For example, starting from Sitecore XP 9.3 Initial Release, Sitecore Blob Storage allows users to store media files in Azure Blob Storage, thereby reducing the hosting costs and improving performance.
    • Create a custom handler for the item:deleting event to delete the proper file. In the handler, get the name of the file from the FilePath field, if it is present in the item and not null, and use the Sitecore.IO.FileUtil.Delete method to delete the file.
    • Delete physical files manually from the file system.

Applies to:

CMS 6+

March 16, 2020
March 16, 2020

Reference number:

90424

Keywords: 

  • Media