Home Forums ACF PRO Image not displaying


Image not displaying

  • Image not showing but the alt text is. I copied the code from the Code Examples page which is as this:

    <?php $image = wp_get_attachment_image_src(get_field('headshot'), 'full'); ?>
    <img src="<?php echo $image[0]; ?>" alt="<?php echo get_the_title(get_field('headshot')) ?>" />

    This is added to a custom post type.

    The image link is:
    The page link is
    Other fields are working but something I’m leaving out…. thanks for your ideas and help.

  • Hi @stinkykong

    If you set the return of the image field to “image object” you can retrieve all information like this:

    <?php $image = wp_get_attachment_image_src(get_field('headshot'), 'full'); ?>
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
  • I’m having the same issue, where the image is not displaying when adding the code into a hooks field in Dynamik Website Builder for Genesis.

    The code I’m using is…

    <div id="eline-home-slider" class="clearfix"> 
    <div class="eline-home-slider-inner">
    <?php $image = wp_get_attachment_image_src(get_field('slider_image'), 'full'); ?>
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />

    Any thoughts or suggestions?

  • Hi @osalcedo

    Please see the edited answer I did above.. I completely blanked on the image object.

    <?php $image = get_field('headshot'); ?>
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
  • I tried that code snippet and it still doesn’t work on the homepage. Apparently ACF has in issue with displaying content on the front page of websites. I’m still trying to figure this out :/

  • Well.. not really. But my guess is that you have a homepage which displays your latest posts and not a static page?

    Otherwise there’s no difference of your homepage and any other page and everything should work just the same. get_field() is basically just a wrapper for wp_get_post_meta with some extra functionality.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Image not displaying’ is closed to new replies.