0

I'm using drupal 8, in my template I created a file named views-view-unformatted--block-12.html.twig and this is it's content:

<div class="row list">
{% for row in rows %}
  {%
    set body = row.content['#row']._entity.get('body').value|striptags|render
  %}
  {%
    set title = row.content['#row']._entity.get('title').value
  %}
      <div class="col-md-3">
        <div class="promotion-slider-item">
          <p class="mb-0">
            <img alt="Title" data-src="/themes/porto/img/abc/maxresdefault.png" class="lazy-load">
          </p>
          <div class="inner">
            <p class="title mb-1">{{ title }}</p>
            <div class="desc">{{ body|length > 70 ? body|slice(0, 70)|raw ~ '...' : body|raw }}</div>
            <a href="/node/{{row.content['#row']._entity.get('nid').value}}" title="{{row.content['#row']._entity.get('title').value}}" class="btn-read-more"><span class="">Read more</span></a>
          </div> <!-- end .inner -->
        </div> <!-- end .promotion-slider-item -->
    </div> <!-- end .col -->
    {{dump(row.field_images)}}
{% endfor %}
</div>

I try to dump(row.field_images) but null and dump(file_url(row.content['#row']._entity.get('field_images').value['0']['target_id'])) but url is /id_sample. How do I fix it?

1

I did with this code row.content['#row']._entity.YOUR_FIELD_NAME.entity.fileuri

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.