0
votes

I am working with ACF Flexible content. I am trying to load an image in my flexible content. But Image doesn't show, just an broken icon.
Why ?
My sub field is named "photo"enter image description here

            <h4 class="titrage2"><?php the_field('titre_1'); ?></h4>


                    <?php

                    if( have_rows('ateliers') ): ?>
                    <?php while ( have_rows('ateliers') ) : the_row(); ?>

                    <?php if( get_row_layout() == 'atelieratelier' ):?>

                                    <div id="article-atelier">
                                    <h4 class="titrage"><?php the_sub_field('atelier_01');?></h4>
                                    <div class="article-details"><?php the_sub_field('txtimg');?></div>         

                                    <div>
                                        <img src="<?php the_sub_field('photo'); ?>" />

                                    </div>

                                </div>

                           <?php  endif;?>

                        <?php  endwhile;?>

                     <?php else :?>


                    <?php endif;?>

1
Your issue is you had it set as an array and were trying to pull in like a URL only.Aibrean

1 Answers

1
votes

Here is the solution

 <?php 
        $image = get_sub_field('photo');
        if( !empty($image) ): ?>

            <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />

    <?php endif; ?>