0

I created a view and added three fields. A title, a link, and an image. When adding the image, I set the formatter as URL to image.

How do I rewrite my in my views so that each recipe can have the thumbnail as a background image instead?

In a way, each view row should be structured like this:

<article class="recipe" style="background-image: url({{ field_recipe_thumbnail }})">
  <h1>{{ title }}</h1>
  <p>{{ content }}</p>
</article>

Is there a way I can do this in my template? Note: The only question closed to mine that I found is here

1 Answer 1

0

Did you override view ?? If your not override view Please follow below views view suggestion -

views-view-fields--(yourviewmachinename).html.twig views-view-unformatted--(yourviewmachinename).html.twig

Note - In views-view-fields--(yourviewmachinename).html.twig,file render your fields which are present in that view Eg. If will have field - title follow below render

{{ fields.title.content }}

Note - If your rendering page title then render {{ label }}

In these file - views-view-unformatted--(yourviewmachinename).html.twig - You will get loop here,don't change here any think.

Hope, this will help you.thanks!

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.