Custom Fields
Re-Envisioned
Support MB Views srcset from Relationship in View

  • Creator
    Topic
  • #30935
    Resolved uptwo
    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #30937
    uptwo
    Participant

    Using Single Image by the way

    #30944
    uptwo
    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 Nguyen
    Moderator

    Hi,

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

    #30948
    uptwo
    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 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 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.