Support

Account

Home Forums Add-ons Repeater Field Responsive images from repeater field Reply To: Responsive images from repeater field

  • You need to have the setting of the field to return image or image IDs. See the image field documtation https://www.advancedcustomfields.com/resources/image/. Either that or your need to get the field unformatted and this will return the ID. get_sub_field('zdjecie', false).

    And that lead to the second part, you need to get the field using get_sub_field because ACF will not do this kind of formatting for you.

    what you do next depends on what your returning.

    If you’re returning an array then you need to get the values you want from that array. If your returning the ID then you need to get the values of the different image sizes yourself, honestly, I’d go with the array because there’s too much code to put it all here.

    At any rate, you need to build the attributes for src and sizes yourself.

    You’re other option is to create an image tag that looks identical to the image tag that WP inserts into the content area of a post and then

    
    $image = 'construct your image tag';
    $image = wp_make_content_images_responsive($image);
    echo $image;