I have created an Image custom field and no matter what I set it’s “Return Value” to (Image Object, Image URL, or Image ID) it always returns the Image ID.
I am trying to use the Return Value in another plugin (Slider PRO) to render the image in a jQuery slideshow.
I’m not sure what I’m doing wrong: http://colbyblogs.org/wptest/custom-post-types/shortcode/
<img src="<?php the_field('field_name'); ?>" alt="" />
I decided to create a child theme so I could inject the PHP directly into the page without having to rely on a plugin. As you can see on the page linked below, the same “bool(false)” happens with the code you provided in the page.php file of the theme.
Any idea why this would happen?
Looking at the source code, I can see that the image has a src of 12. This means that the value returned is the image ID.
Perhaps you are not correctly using the get_field` function to retrieve the formatted value?
Can you post the code you are using to render the slider?
What type of field is
How do you handle multiple images?
Are you sub fields within a repeater field?
What code are you using to render the slider?
Did you place the var_dump code within your loop (alongside functions like the_content)?
The artwork_image field is an Image field set to return the Image URL.
I have the field assigned to a custom post type.
I’m not sure what “sub fields” and “repeater field” mean.
I’m using a plugin called Slider PRO to render the slider. It allows for custom fields to be used to generate content in the slider (images, captions, etc) and my Text fields work for the captions (see “media” and “artist”) but the Image field only returns the Image ID, never the URL.
I accidentally placed the var_dump outside the loop, but I have since corrected that and still get bool(false).
The image field will always save it’s data as the attachment ID, then when using the
get_field function, the value will be modified based on the return value setting.
This explains why your slider plugin is not able to read in the image.
Perhaps you can ask the developer of the slider plugin how you can make this compatible with ACF when ACF save’s it’s image custom field data as the attachment ID, not the attachment URL.
the_field() and the Image ID is returned instead of the expected return value, this is a sign that
acf_add_local_field_group() was not run. Therefore ACF is pulling the raw value from the database but has no way to determine in which format you want it.
To resolve the issue, ensure that
acf_add_local_field_group() is run from the
init hook, not one of the
The topic ‘Image File Type Return Value not working’ 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!