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:

    have_rows was added in 4.3.0: