Skip to main content

Drupal 10 File Settings

$config['file.settings']['make_unused_managed_files_temporary'] = TRUE;
$config['system.file']['temporary_maximum_age'] = 86400; // keep temp files for one day

Configuration options that affects how unused managed files are handled.


  • This setting in Drupal's configuration system determines the behavior of managed files that are no longer in use. 


  • When set to TRUE, any managed file (i.e., a file that is tracked in the file_managed database table) that isn't referenced anywhere (not used in any content or by any module) will be marked as temporary.
  • Drupal periodically cleans up temporary files based on the "Temporary files deletion threshold" (usually during cron runs). If a file is marked as temporary and not used for a certain period, Drupal will automatically delete it.
  • The idea is to help manage disk space by automatically cleaning up files that are no longer in use.

Use Case:

  • This setting is particularly useful in scenarios where your site has a lot of file uploads and deletions, as it helps prevent the accumulation of orphaned files.
  • It's commonly used in sites with heavy content creation and deletion, like media sites, educational platforms, or any site where users upload a lot of content that might not be needed indefinitely.


  • This line can be added to your site's settings.php file or a relevant configuration file for your environment.
  • It's part of Drupal's file system settings and can be modified according to your site's file management needs.


  • Before enabling this setting, consider how your site uses files. If there are cases where files might be used infrequently but should be retained, you might need to manage those files differently.
  • Regularly monitor the behavior of your site's file cleanup after enabling this setting to ensure it aligns with your content management strategies.

Remember that while this setting can be very useful for managing files, it should be used in conjunction with a well-planned content and file management strategy.