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: http://dentoncountycollaborativeprofessionals.com/wp-content/uploads/2015/09/sean.jpg
The page link is http://dentoncountycollaborativeprofessionals.com/memprofile/sean-abeyta/
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']; ?>" />
</div>
</div>
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.
The topic ‘Image not displaying’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.