I have a content type with a private image field. I would like to render the image on the twig template in order to show it to the user when it has enough permission, but the image source is a private directory and I don't know what could be the path to show it.
1 Answer
Normally you would configure the formatted output of an image field in the content type and then render it in the node template:
{{ content.field_image }}
{{ content|without('field_image') }}
If you want to access the path of a private file directly then use the file scheme private://
:
{{ file_url('private://foo.jpg') }}