- π¨πSwitzerland sir_squall
in Drupal 11, I'm using in the node.html.twig this code:
{{ dump(node.field_image|file_uri) }}
And I have two content rendered, one with a default image value setup in the content type, and the result is null and if I upload manually an image I got the uri, do you know if I need to do something?
Thanks
Alcindo - π·πΊRussia Chi
The logic for loading default image is in the image formatter. You may invoke it like follows
node.field_image|view
.
However, if you only need a raw image URI you have to use preprocess hook to fetch default image from field storage settings. - π¨πSwitzerland sir_squall
mmmhh ok, maybe you could help me, I have updated the code to that:
{{ node.field_image|view|add_class("logo") }}
But the class is not showing, and in the image.html.twig i have the standard code:
<img{{ attributes }} />
I wanted to retrieve the uri, like that I could create my self the
I don't know if you could help
- πΊπΈUnited States jwineichen
I'm having some difficulty getting the streamlined file_url filter to work with image_style correctly. Not sure if it's a bug in the code or user error.
When I use this:
{{ node.field_media_image[0].entity.field_media_image.entity.uri.value|image_style('thumbnail') }}
...it correctly generates this:
/sites/www.mydomain.org/files/styles/thumbnail/public/2025-01/image.jpgBut when I use this:
{{ node.field_media_image|file_url|image_style('thumbnail') }}
...it adds an extra /sites/www.mydomain.org/files into the middle of the url:
/sites/www.mydomain.org/files/styles/thumbnail/public/sites/www.mydomain.org/fi...