If I have view with fields:

field title [hidden]
field text [hidden]
field image [hidden]
field display

and I make rewrite in "display" field with "title" and "text" field added, how can I print content of field "image" (url of this image) with views-view-field--field_display.html.twig? I need wrapper with image url from this field. I see all available variables (view, field, row, output) in template and suggestion to fetch output with construct:

data = row[field.field_alias]

but when I try to write twig code with my field_image alias it's not showing me anything. Field with image is set up to display just url to image. I translated few code lines from drupal 7 to twig, but I am unable to see anything in kint, just dump show me some key strings. Views create block and I am placing this block on my page.

What I am doing wrong?

  • you want to print the image url? is that your question?
    – No Sssweat
    Commented Feb 22, 2016 at 22:05
  • Yes. It will be for field wrapper. Field are set up to display with HTML list, each field in list is <li class="slide"> content with title and text</li> and I want to wrapp each slide with image <div style="background-image: url( {{ field_with_image_url }} ) > {{ output -}} <div>
    – Jack
    Commented Feb 22, 2016 at 22:09

1 Answer 1



This module add a url formatter for image field. Then you can output image url directly.

Enable the module, then in views, click on your image field, and change the Formatter to Image url.

{{ fields.field_image.content }}  // will display url instead of picture
  • @Jack how did it go?
    – No Sssweat
    Commented Feb 23, 2016 at 0:57
  • I've figured out that I have already installed that module, turned on and this field is set up to display url. I think I put wrong twig to print that field. What I am doing now is trying to display my field in views-view-fields--myview.html.twig not in views-view-field--myfield.html.twig but not success yet.
    – Jack
    Commented Feb 23, 2016 at 1:13
  • I want to wrapp each slide is each slide is a row? and what is {{ output }} ?
    – No Sssweat
    Commented Feb 23, 2016 at 1:21
  • NOW IT WORKS! I tried to overwrite a wrong template file, in the template for all rows for fields it working just perfect! Now it's time to twig it in my complicated way! Thank you again for support!
    – Jack
    Commented Feb 23, 2016 at 1:28

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.