Home › Forums › Add-ons › Repeater Field › First row of repeater field that returns Image Object › Reply To: First row of repeater field that returns Image Object
This is the code I have so far but I am not getting the image url to echo into the inline style for background-image on the mobile-bg div.
<?php $rows = get_field('slider'); // get all the rows $first_row = $rows; // get the first row $first_row_image = $first_row['slide']; // get the sub field value // Note // $first_row_image = 123 (image ID) $image = wp_get_attachment_image_src( $first_row_image, 'full' ); // url = $image; // width = $image; // height = $image; ?> <div class="mobile-bg visible-xs" style="background-image:<?php echo $image; ?>"></div><!-- end mobile-bg -->
I don’t think I need this code
$image = wp_get_attachment_image_src( $first_row_image, 'full' ); but I don’t know what to put in its place.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.