0
votes

How to add background in Drupal 8 views-view-fields.html.twig' files.

I try like this but it's don't work. Using views I just output image paht.

 <div class="cover-img" style="background:url('{{ field_image_1 }}');">
    </div>

Thank you

1

1 Answers

1
votes

you are best to do that in your css file by doing this:

.cover-img { background: url('/sites/all/themes/....); }

if you have to put it in your twig file, first make sure its even outputting the correct img url by putting that field_image_1 into an empty div element.