3

I've got an image field, in which I'm showing the image using url by setting the relationship for that field on 'Advanced' tab to get the url of the field.

I'm getting the url of the field as

{% set image = file_url(fields.uri.content|striptags|trim) %}
    <div class="mob"><img src="{{ image }}" class="testimonial-mob-img" alt="" /></div>

I would like to know how to get the alt of the image on views-view-fields-view-machine-name.html.twig.

0

1 Answer 1

5

A simple solution is to add image again as a field and Rewrite Results:

enter image description here

Now in your template:

... alt="{{ fields.field_image_1.content|striptags }}" ...

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.