So I have this Node:
object(Drupal\node\Entity\Node)[1862]
protected 'values' =>
array (size=17)
'vid' =>
array (size=1)
'x-default' => string '7' (length=1)
'langcode' =>
array (size=1)
'x-default' =>
array (size=1)
0 =>
array (size=1)
'value' => string 'en' (length=2)
... (more fields)
'field_image' =>
array (size=1)
'x-default' =>
array (size=1)
0 =>
array (size=5)
'target_id' => string '1' (length=1)
'alt' => string '' (length=0)
'title' => string '' (length=0)
'width' => string '150' (length=3)
'height' => string '120' (length=3)
Now the field_image has an array with x-default and some basic image data. How do I show the image, or create a link to the image inside the Twig template?
url(node.field_image.0.entity.uri)
(relevant issue)Recoverable fatal error: Object of class Drupal\Core\Field\FieldItemList could not be converted to string
so I tried it with this:url(node.field_image.0.entity.uri.value)
but then it just tells me this:Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Route "public://image.png" does not exist.")
FieldItemList
s into a string representation (which I can't find)url()
wants a route. How abouturl_from_path(node.field_image.0.entity.uri.value)
?url_from_path()
seems to generate this:http://mywebsite.local/public%3A//image.png
so it seems to be urlencoding and appending the exact value to the url