Protected file formatter settings
Protected file form element

Protected file module provide a new field type which extends File field and permit to enable/disable for each file the possibility to prevent users to download the file, if they don't have the right permission, whereas the file is still visible on the page.

This module is useful if you want to prevent users to download file, but you want display the file regardless.


This module provide a new field type "Protected file" based on the File field type. File is provided by Drupal core.

This module requires that the private system file is available.


Field permissions permit to set permissions on fields, and then can prevent users to access to file uploaded with a File field. But users without the permissions don't see then the file attached to an entity.

Protected file permit to display every files, but can prevent users to download them. This can be useful if you want that users have to register to be able to download some (specific) file(s).


Install as you would normally install a contributed Drupal module. See:
for further information.


  • Create a "Protected file" field on an entity
  • Configure the field settings as the standard File field (directory, extension, etc.)
  • Configure the field formatter : you can specify if the file is downloaded in a new tab, the redirect path for users without permissions, if the redirect path is open inside a modal or not, and the text used for the title link
  • Configure the permissions to allow Roles to download protected file
  • Create content and upload some files. For each file you can protect them by checking the protected checkbox

You can override the twig template protected-file-link.html.twig if you want
customize the feel and look of your protected files.

By default, the module provide and inject a markup based on a fontawesome class for protected
files (fa-lock icon). This markup is available in the {{ icon }} twig variable. You can easily
override it in the template or in a preprocess fonction.

This module was sponsored by Cerema.

Supporting organizations: 

Project information