Support

Account

Home Forums Add-ons Options Page Get the value (image url) of custom size in a repeater

Solved

Get the value (image url) of custom size in a repeater

  • Hello I’m trying to get the value of the image url with the custom size but it is not working.

    I tried with the example you gave in the images documentation page but i think I’m doing something wrong as i changed get_field to get_sub_field as i have the image in a Repeater..

    There is no problem with cropping the image in the admin with Options add-on page but just can’t get the values to display the cropped image.

    Thanks`<!–Featured Image Slider–>
    <?php if(get_field('orbit_slider', 'option')): ?>
    <?php while(has_sub_field('orbit_slider', 'option')): ?>

    <li>
    <?php $attachment_id = get_sub_field('orbit_image');
    $size = “customsize”;

    $image = wp_get_attachment_image_src( $attachment_id, $size );
    // url = $image[0];
    // width = $image[1];
    // height = $image[2];
    ?>
    <img src=”<?php echo $image[0]; ?>” />
    </li>

    <?php endwhile; ?>
    <?php endif; ?>
    <!– End Featured Image Slider–> `

  • okay it took me sometime but figured it out till the end

    I had to add the ‘option’ when calling for the image field

    <?php $attachment_id = get_sub_field(‘orbit_image’, ‘option’);

    🙂

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.