Home › Forums › Bug Reports › image field doesn't return image url
Hello,
I’m creating an image field that names as “thumb” I want to place here a full url of the image, that’s why I’m selecting “Return Value” as “Image URL”
But script allways places “Image ID”
Am I doing it wrong?
Thanks
I think I found some thing
image.js line 77 and 78 don’t care what type of return value needed. Those lines always prints image.id
Change line 78 to
div.find(‘.acf-image-value’).val( image.url ).trigger(‘change’);
fixed my problem but it is still buggy.
Hi @fobus
ACF will always save the attachemnt ID.
It is the get_field function which will then convert the ID into the ‘return format’.
Is it possible that you are not using the get_field function correctly?
Hi all,
I’m new using this plugin and I have the same issue here.
I have this code:
<?php $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?>
<?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
<li>
<a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>">
<div class="subdivision">
<?php
if (get_field('sub_division_image')){ ?>
<?php the_field('sub_division_image'); ?>
<?php } else {
echo "Hello world";
} ?>
</div>
<p><?php echo $pageChild->post_title; ?></p>
</a>
</li>
<?php endforeach; endif; ?>
But there is no way to get the image to show up on my page. If I use the plugin as a custom text field it will work just fine. Any help would be very appreciated!
Thanks.
GM
Hi @gmartins
Have you read over the documentation for the image field?
your code shows no sign of an img tag. That is your first mistake.
Cheers
E
Hi @elliot.
Sorry my bad.
That was some older code. I did in fact use a img tag but to no success.
<?php $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?>
<?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
<li>
<a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="<?php echo $pageChild->post_title; ?>">
<div class="subdivision">
<?php
if (get_field('sub_division_image')){ ?>
<img src="<?php the_field('sub_division_image'); ?>" alt="<?php echo $pageChild->post_title; ?>" />
<?php } else {
echo "Hello world";
} ?>
</div>
<p><?php echo $pageChild->post_title; ?></p>
</a>
</li>
<?php endforeach; endif; ?>
Any thoughts?
Cheers,
GM
Just like the rest of the code, you need to send through a reference to the post object to load from. This is done like so:
<img src="<?php the_field('sub_division_image', $pageChild->ID); ?>" alt="<?php echo $pageChild->post_title; ?>" />
The topic ‘image field doesn't return image url’ 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.