Home › Forums › General Issues › image Alt Text Issue › Reply To: image Alt Text Issue
Hi
As you can see you haven’t inserted an alt text in your code:
<img src="<?php the_sub_field('post_slider_image');?>">
So you would need that. What return value are you using in your image field settings? Must be URL. So you would need to change that into “Image Array”.
In your code you would define the image as:
<?php $image = get_sub_field('image'); ?>
And print it out like:
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
Also, the has_sub_field function is outdated, see:
https://www.advancedcustomfields.com/resources/has_sub_field/
have_rows was added in 4.3.0:
https://www.advancedcustomfields.com/resources/have_rows/
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.