i have a similar problem with Ie 8 and the field image.
With the comptability ie 7 on the browser ie 8, it’s ok the picture are visibly, but only with ie 8 there ‘s no picture.
i use this :
<?php $image = wp_get_attachment_image_src(get_field(‘image_bloc_2’), ‘medium-3’); ?>
” alt=”<?php echo get_the_title(get_field(‘image_bloc_2’)) ?>” />
When i use the url and not the id, i can’t use the size of the image.
you can see it here: http://www.vertikaro.com
with firefox, safari chrome, it’s ok,
can you help me ?
I have split this comment into it’s own topic as it was very different to the original.
To get a specific ‘size’ for an image, you MUST use either ID or Array as the return type. I can’t explain why it is working for you in firefox + URL, but I can only hope it is a caching issue.
Please use either ID or Array as instructed in the documentation.
Because PHP runs on the server and is not browser dependent, the issue cannot be related to a browser.
The fact that it works on ie, and not firefox is down to something else. Perhaps some JS running on the page or some caching going on.
Lets fix your code logically. First, lets debug the value returned by get_field. You can do this by:
<?php echo '<pre>'; print_r( get_field('image_bloc_2') ); echo '</pre>'; die; ?>
What do you get from that?
Next is to debug the returned value from the wp_get_attachment_image_src function.
What do you get for that?
You can find docs on that function here:
Please note that this function returns an array and the src is actually at $image. This means that your code won’t work because you are trying to echo an array.
Please read over the image field documentation to get a better understanding of how to use this function.
The code you pasted above is the PHP code which you are using to debug.
Can you please view the source of the page and find the pre tags in the HTML? What is within the pre tags?
Please wrap any code within the ‘code’ button tags when commenting.
Thanks for the info. We can confirm that the get_field function is returning the correct data.
In a previous comment, I mentioned that the function you are using “wp_get_attachment_image_src” returns an array of data, not just a string. Have you taken this into consideration with your code and output the src like so:
<?php $image = wp_get_attachment_image_src(get_field('image_bloc_2'), 'medium-3'); ?> <img src="<?php echo $image; ?>" />
The topic ‘Image not showing correctly’ 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!
© 2022 Advanced Custom Fields.