Home › Forums › General Issues › AC5 Image Issue
Since upgrading from AC4 to AC5 a weird issue has happened to a couple of the images that are set from the Options location.
They display fine on certain pages (You’ll need to log in: guest guest):
http://www.lgbttravelclub.com/restaurants/
But on others it is echoing the ID rather than the URL:
http://www.lgbttravelclub.com/united-kingdom/london/?type=restaurants
<?php $background = get_field('background_image', 'option'); ?>
html {
background-image: url('<?php echo $background['url']; ?>');
}
<?php $logo = get_field('header_logo', 'option'); ?>
<div class="logo"><a href="<?php bloginfo('url'); ?>"><img src="<?php echo $logo['url']; ?>"></a></div>
They were working fine prior to the upgrade.
Any ideas?
Many thanks,
Ashley
Is the image stored as a ID or URL on the option page?
When de field is stored as a ID u must get the image URL of the image ID.
Eduard
Hi Eduard,
The Image was stored as a URL, but when the issue started occurring I switched it to object and started using [‘url’] to obtain the URL, but for some reason on the Taxonomy archives this is ignored, despite using the exact same PHP template!
Ashley
Here is the var_dump for the home page (Where the image is displayed correctly):
array(9) { ["ID"]=> int(6) ["alt"]=> string(0) "" ["title"]=> string(7) "LGBT-BG" ["caption"]=> string(0) "" ["description"]=> string(0) "" ["url"]=> string(68) "http://www.lgbttravelclub.com/wp-content/uploads/2014/04/LGBT-BG.jpg" ["width"]=> int(1600) ["height"]=> int(1031) ["sizes"]=> array(9) { ["thumbnail"]=> string(76) "http://www.lgbttravelclub.com/wp-content/uploads/2014/04/LGBT-BG-400x400.jpg" ["thumbnail-width"]=> int(400) ["thumbnail-height"]=> int(400) ["medium"]=> string(76) "http://www.lgbttravelclub.com/wp-content/uploads/2014/04/LGBT-BG-800x515.jpg" ["medium-width"]=> int(800) ["medium-height"]=> int(515) ["large"]=> string(77) "http://www.lgbttravelclub.com/wp-content/uploads/2014/04/LGBT-BG-1200x773.jpg" ["large-width"]=> int(1200) ["large-height"]=> int(773) } }
And taxonomy archive where it is not (Despite using same dynamic-css.php file included in the header)
string(1) "6"
The topic ‘AC5 Image Issue’ 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.