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 1


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') }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.