How can I add styles attribute to Global Custom field markup? I have created a view to display my articles and I would like the article thumbnails to be used as background.
So I added the different fields I've hidden.

I added a relationship to the image field to get the thumbnail URI. Then I added the following code in the custom global field.

&lt;div class="post-datas" style="background-image: url('{{ uri }}')"&gt;
&lt;span class="category-art"&gt;{{ field_categorie }}&lt;/span&gt;
&lt;h3 class="title-art"&gt;{{ title }}&lt;/h3&gt;
&lt;span class="date-art"&gt;{{ created }}&lt;/span&gt;
&lt;/div&gt;


But on display, the style is ignored.

Instead of &lt;div class="post-datas" style="background-image: url('http://adresse"&gt;, I have &lt;div class="post-datas"&gt;.

How can I make Views to print the style attribute to let me put a dynamic background image URI?
Drupal 8 views will strip away any markup it thinks it is dangerous

you have to rely on a custom theme solution here is a general overview of how this can be done


if you don't have a custom theme you have to create one (more info)
Enable Twig debugging (more info)
Inspect your page in browser to find the appropriate templates to override.  In the html comments you will find which .twig template is responsible to output a specific piece of html markup  (More info)
Copy required template into your CUSTOM_THEME/theme folder
Add or modify the markup in the twig template


Alternatively you might want to give https://www.drupal.org/project/viewscss a try which promises to allow viewscss but it does not have a stable release.