plugins - URL path image error in ACF (Advanced Custom Field)

Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

I am using Advanced Custom Fields plugin as a repeater and I can get it to work except for the image which doesn't load.

Can anyone see where the error might be?

     <?php

// check if the repeater field has rows of data
if( have_rows('top_ten') ):

    // loop through the rows of data
    while ( have_rows('top_ten') ) : the_row();

  // vars
  $im = get_sub_field('tool_image');

  //      $tool_image = get_field('tool_image');
  if( !empty( $im ) ):
  ?>


  <div class="col-md-12">
      <div class="row my-5">
          <div class="col-md-6">
              <img src="<img src="<img src="<?php echo esc_url($im['url']); ?>" alt="<?php echo esc_attr($im['alt']); ?>" class="top-ten">
              <div class="col-md-12">
                  <div class="row mt-3">
                      <div class="col-md-6">
                          <a href=""
                              class="btn btn-primary rounded-0 my-3 p-3 w-100 text-uppercase" href="#" role="button">
                              <?php the_sub_field ('button_learn'); ?>
                          </a>
                      </div>
                      <div class="col-md-6">
                          <a href=""
                              class="btn btn-primary rounded-0 my-3 p-3 w-100 green-bg text-uppercase" href="#" role="button">
                              <?php the_sub_field ('button_learn'); ?>
                          </a>
                      </div>
                  </div>
                  <div class="row">
                      <div class="col-md-12">
                          <p style="text-align: center;">
                            <?php the_sub_field ('tool_category_description'); ?>
                          </p>
                      </div>
                  </div>
              </div>
          </div><!-- .end // col-md-6 -->

          <div class="col-md-6">
              <h1 class="h1-responsive pt-3 mb-4 text-uppercase top-ten-header">hacker</h1>
              <p class="lead nicered text-uppercase"><?php the_sub_field ('tool_category_description'); ?>​</p>
              <p class="lead text-uppercase"><?php the_sub_field ('tool_cost'); ?></p>
              <div class="content">
                  <p><?php the_sub_field ('tool_description'); ?></p>
              </div>
          </div><!-- .end // col-md-6 -->

      </div><!-- .end // row my-5  -->
  </div><!-- .end // col-md-12 -->

  <?php
    endif;

      endwhile;

  else :

      // no rows found

  endif;

  ?>

Appreciate any help / direction with this - thanks!

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

I am using Advanced Custom Fields plugin as a repeater and I can get it to work except for the image which doesn't load.

Can anyone see where the error might be?

     <?php

// check if the repeater field has rows of data
if( have_rows('top_ten') ):

    // loop through the rows of data
    while ( have_rows('top_ten') ) : the_row();

  // vars
  $im = get_sub_field('tool_image');

  //      $tool_image = get_field('tool_image');
  if( !empty( $im ) ):
  ?>


  <div class="col-md-12">
      <div class="row my-5">
          <div class="col-md-6">
              <img src="<img src="<img src="<?php echo esc_url($im['url']); ?>" alt="<?php echo esc_attr($im['alt']); ?>" class="top-ten">
              <div class="col-md-12">
                  <div class="row mt-3">
                      <div class="col-md-6">
                          <a href=""
                              class="btn btn-primary rounded-0 my-3 p-3 w-100 text-uppercase" href="#" role="button">
                              <?php the_sub_field ('button_learn'); ?>
                          </a>
                      </div>
                      <div class="col-md-6">
                          <a href=""
                              class="btn btn-primary rounded-0 my-3 p-3 w-100 green-bg text-uppercase" href="#" role="button">
                              <?php the_sub_field ('button_learn'); ?>
                          </a>
                      </div>
                  </div>
                  <div class="row">
                      <div class="col-md-12">
                          <p style="text-align: center;">
                            <?php the_sub_field ('tool_category_description'); ?>
                          </p>
                      </div>
                  </div>
              </div>
          </div><!-- .end // col-md-6 -->

          <div class="col-md-6">
              <h1 class="h1-responsive pt-3 mb-4 text-uppercase top-ten-header">hacker</h1>
              <p class="lead nicered text-uppercase"><?php the_sub_field ('tool_category_description'); ?>​</p>
              <p class="lead text-uppercase"><?php the_sub_field ('tool_cost'); ?></p>
              <div class="content">
                  <p><?php the_sub_field ('tool_description'); ?></p>
              </div>
          </div><!-- .end // col-md-6 -->

      </div><!-- .end // row my-5  -->
  </div><!-- .end // col-md-12 -->

  <?php
    endif;

      endwhile;

  else :

      // no rows found

  endif;

  ?>

Appreciate any help / direction with this - thanks!

Share Improve this question asked Dec 15, 2019 at 2:07 HenryHenry 9831 gold badge8 silver badges31 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

There are a couple of different ways to work with the ACF image object, depending on the return type: https://www.advancedcustomfields/resources/image/. It looks like you're working with an array, but you've got some extra image attribute markup. Try something like this:

<img src="<?php echo esc_url($im['url']); ?>" alt="<?php echo esc_attr($im['alt']); ?>" class="top-ten">

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744903339a4600108.html

相关推荐

  • plugins - URL path image error in ACF (Advanced Custom Field)

    Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress.

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信