2

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.

5

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') }}
| improve this answer | |

Your Answer

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

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