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
Thanks! I am not quite following how to integrate this with the demo code for finding the first row of a repeater field found here:
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[0]; // 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[0];
// width = $image[1];
// height = $image[2];
?>
<div class="mobile-bg visible-xs" style="background-image:<?php echo $image[0]; ?>"></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.
Thanks!
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.