How can i get the list of images url's in twig template, Drupal 8?

Solutions

Check this out: https://www.drupal.org/project/slick

The advantage with this module is that it's already responsive and comes with a lot of features and configuration options.

As a general tip: whenever you think about coding something very common (image slider/gallery) yourself, research if there's already a module for that, because chances are there is! You don't need to re-invent the wheel ;-)

But anyway, how to get the urls of a multi-value image field? Like this:

<ul>
  {% for item in content.field_banner_image['#items'] %}
    <li>{{ file_url(item.entity.uri.value) }}</li>
  {% endfor %}
</ul>

Hope this helps.

Tags: Drupal / Twig / Drupal 8

Similar questions

How do I make twig variables available in node.html.twig accessible in my html.html.twig?
I have a boolean field on my Content Type called 'field_bootstrap'. I have some twig logic in my node.html.twig file that, if the field is set to true, includes Bootstrap via HTML inclusion. What I need is the ability to use my {{ node.field_bootstrap }} logic in the html.html.twig template, instead of the node-level template. This would allow me t...
How to get the valid URL of a Link field from within a Twig template?
I have a Link field named field_my_link (machine name). Within a Twig template I can get the link's URL value with this: If inside the Link's URL there is an external URL, e.g. http://example.com it works good. But, if inside the Link's URL there is stored an internal URL, e.g. "/node/11", I get a value like this: with the "internal:" prefix. How c...
How do I get the node URL in a Twig template?
I am trying to get the node URL in a Twig template. {{ content.node_link }} returns the full link, but I only need the URL. How do I retrieve the node URL?
How to get the value / URL of a Link field in a Twig template?
I have a custom block Type with a Link field called "field_link" (for internal links only). Within my block Twig template I want to extract the URL of the link field. How can I do that? I read some post with similar problems, but none of the solutions seems to work so far. What I tried so far: I only get "/" but there should be "/node/1"... This is...
How to get an image URL from a field in a twig template
I have a node that contains various fields. I am able to get the values of text fields but not an image field. Below is the relevant output of the node variable being dumped in the twig template: I have seen similar questions on SE, like this one Getting the image URL from a field_image on a node, but none of the answers have worked for me. Thanks ...
Get path/url/uri of Entity reference field to content in a Twig template?
I have a Entity reference field which links to internal content/node. I can get the title with {{ node.field_related_project_internal.entity.label }} But how can I get the raw path/url/uri of the linked content/node? The soloutions for a Link Field to not work here: How to get the valid URL of a Link field from within a Twig template?

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.