2016-01-03 83 views
0

我正在使用ACF靈活內容。我正在嘗試在我的靈活內容中加載圖像。但圖片不顯示,只是一個破碎的圖標。
爲什麼?
我的子場被命名爲「照片」 enter image description hereACF靈活內容 - 圖像不顯示

  <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;?> 

+0

你的問題是你必須將它設置爲一個數組,並試圖拉只有一個URL。 – Aibrean

回答

0

下面是解

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

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

    <?php endif; ?>