We have private nodes. Nodes that are just visible for logged in users. These nodes are setup to use a private filesystem. These "private" nodes can also become public if an article is moved to the front page for example - or when an editor decides, that the content is not just for members any longer.

I assume all images uploaded before via the private file system setup now will not work any longer.

I guess I could check every single file via hook (if there is one) and check the access settings for the parent entity (node). But I am pretty sure I am not the first person, that needs to switch content from private to public. There must be a more solid way.

I could not find any information regarding this in the documentation.

Whats Drupals way to deal with dynamic (public / private) states and its media?


  • I once needed to make all public files private drupal.stackexchange.com/questions/264496/…
    – leymannx
    Oct 2, 2020 at 20:11
  • And I'm not sure, isn't it that private files only are private as long as the host entity also is private? So that when you switch the nodes the private files also become accessible? I'd definitely check that first, just to be sure to make no false assumptions.
    – leymannx
    Oct 2, 2020 at 20:12
  • Thanks for the reply. May I ask how you would define if the node (entity) is private?
    – mogio
    Oct 2, 2020 at 20:25
  • Access protected. You used that term in the first sentence of your post. ;)
    – leymannx
    Oct 2, 2020 at 21:30
  • With private nodes I mean nodes that are role specific not visible to NOT logged in users. Is Drupal able to set files of a unpublished or not publicly accessible node to "private" (private filesystem)? fyi: we use symfony for via event to throw a "\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException();" to prevent users from accessing a specific node when he/she has not the correct role. I guess this is wrong?! Should I use a module, that also handles the file privacy ? Thanks for any input.
    – mogio
    Oct 2, 2020 at 21:57


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.