Home › Forums › Add-ons › Repeater Field › Img src stays empty › Reply To: Img src stays empty
Your code contains a few errors:
1. You have selected a return type of ID on the image field. This will cause $product[‘product_image’] to contain and ID of the image
2. Your code references $product[‘sizes’][‘product_image’], but this will never exist. The image ID will sit at $product[‘product_image’]. This is an ID, not a URL
I think what you want to do is set the image return type to ‘Image Object’, then use this code:
echo '<img src=”'.$product['product_image']['sizes']['product_image'].'”>';
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.