Getting the image URL from a field_image on a node

Solutions

I don't know about Twig, but you get the file URI with $node->field_image->entity->getFileUri() in PHP, and the you need to call file_create_url() on that:

file_create_url($node->field_image->entity->getFileUri())

I don't know if that is possible in twig. If it's not possible, you can always calculate it in preprocess and add as a new variable.

Here is an update version of for this answer after 8.0.x. This base on @joelpittet comment.

{{ file_url(node.field_image.entity.fileuri) }}

If someone needed a styled image:

$styled_image_url = ImageStyle::load('large')->buildUrl($node->field_image->entity->getFileUri());
Tags: Media / Drupal 8 / Theming

Similar questions

How to get the field_image path with Twig in Drupal 8
To make an animated slider, I overwrite a fields view template file in my own template named: views-view-fields--slider.html.twig Inside that file I have access to a fields array to print out all the fields that are in my content-type slide. The problem is that I need to get the path of the image file instead of the image itself, because I need the...
drupal 7 frontpage image scroller: getting image URL in overwritten view template?
I am creating a frontpage image scroller. I have created a new content type with a title, blurb and image field, and created a view block and set it up on the frontpage. All good so far; this works. I obviously want to use some javascript and custom HTML to create the image scroller so I have overwritten the views 'row style output' template (views...
Taking over a url and getting variables from url
I have a (non drupal bound) table, that I need to display within my site. It has information about "runs": userID (drupal) - runID - name - distance - ... etc I want to go to site/run/runID and display the data of that particular run. I don't know if there is an easy way of doing it without having to create a custom module for it? I basically just ...
Getting user photo url and profile url using views_json
I'm using the views_json module in Views Datasource to send some information in JSON format to a related website. I've got a bunch of content views built, but now I'm trying to build staff pages. I've got most of it working fine, but when I try to add the user picture I end up with an empty field, When trying to find a url for the user's profile pa...
Getting the source URL of image in Media Gallery Module
I need one more thing to get my custom lightbox running in the Media Gallery module for Drupal 7. The link that is clicked which leads to a custom page which contains the image is at this moment the following: The thing is that I want to link directly to the image, and not to a page where the image is on! I know that this is hard to understand so I...
Getting image URL and rewrite results for Views Module
I have a Content Type of only an Image field and I am using Views module to create a view for it as in follows Using Image URL Formatter module I was able to get the image absolute URL, but using the following "rewrite rule" in Views It outputs the URL wrapped in a or tags, how can I possibly get the pure text URL for this image?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.