srcset from Relationship in View

Support MB Views srcset from Relationship in ViewResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30935
    uptwouptwo
    Participant

    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?

    #30937
    uptwouptwo
    Participant

    Using Single Image by the way

    #30944
    uptwouptwo
    Participant

    Hey,

    this is falsely marked as resolved. I still can't get srcset for my images. I just included the comment above for further informations.

    #30947
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please refer to this topic to use the srcset attribute in View https://support.metabox.io/topic/generating-srcset-code-in-views-twig/

    #30948
    uptwouptwo
    Participant

    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!

    #30983
    Long NguyenLong Nguyen
    Moderator

    Hi,

    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 }}">
    
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.