Meta Box
Support › MB Views › srcset from Relationship in ViewResolved
Hey,
i'm trying to get srcset from a relationship post in a view.
{% set profilbild = mb.rwmb_meta( 'mitarbeiter_profilbild', '', post.ID ) %}
<img class="sec-mitarbeiter-image" src="{{ profilbild['full_url'] }}" alt="{{ profilbild['alt'] }}" title="{{ profilbild['title'] }}" height="{{ profilbild['height'] }}" width="{{ profilbild['width'] }}" srcset="{{ profilbild['srcset'] }}" draggable="false">
But srcset isn't working. Everything is fine, except the srcet. What am i doing wrong?
Using Single Image by the way
this is falsely marked as resolved. I still can't get srcset for my images. I just included the comment above for further informations.
Hi,
Please refer to this topic to use the srcset attribute in View https://support.metabox.io/topic/generating-srcset-code-in-views-twig/
srcset
Hey, thanks for you answer.
I already saw that thread, but can't get it to work. Could you edit my code above and show me the right way?
Thank you in advance!
You need to access the elements of an array in View via the dot ., like an object. For example:
.
<img src="{{ profilbild.full_url }}" srcset="{{ profilbild.srcset }}">