Home Forums Front-end Issues Trouble with Image Object vs Image URL


Trouble with Image Object vs Image URL

  • I have inherited a site using ACF. I am having trouble with and image’s return value. It is set to “Image Object”. On one page, the image shows up fine. On another, it doesn’t show up. If I switch the Return Value in ACF to “Image URL” it will now work on the page that it previously wasn’t showing and then break on the page where it was. Both pages are setup the same.

    <?php $Member = get_field('image'); ?>

    Then <img src="<?php echo $Member['url']; ?>">

  • both pages have the same field? or is one page trying to get the image from the other page?

    have you tried re-saving those fields on each page?

  • The image field is on a single post. That post is pulled to a couple pages. I just deleted the image and reconnected it. No dice. Still not working. Very weird.

  • Hi @lcg_1111

    Could you please debug the returned image using var_dump? This page should give you more idea about it:


  • I tried DEBUG and nothing significant came up.

    I also tried the

    $image = get_field('image');
    echo '<pre>';
    	var_dump( $image );
    echo '</pre>';

    But nothing happened there either. Was some text supposed to show on the page? I haven’t used

    I tried changing it to this:
    <?php $Member = get_field('image');
    						echo '<p class="Test">&nbsp;';
    echo '</p>';?>

    Interesting thing is that I do not see <p class="test"> </p> when I view source. It's like that php isn't happening.

    While I have the code asking for only the ['url'], it gives me the entire array. It's very confusing.

    I tried rebuilding a fresh page using the template, but the error continues. Not sure why one page it works and the other it doesn't.

    BUT I FIXED IT. It makes no sense, but it works. Since I was getting nowhere on the one page I went to the other page and I changed this:
    <img src="<?php echo $SingleMember['url']; ?>" alt="<?php echo $SingleMember['alt']; ?>"/>

    to this:

    <img src="<?php the_field('image'); ?>" alt="<?php echo $SingleMember['alt']; ?>"/>

    And now it works on both pages. The setting in ACF is now Return Value: "Image URL"

  • I lose the alt tag info with this fix, but it’s better than not showing the image.

  • Hi @lcg_1111

    Could you please share the PHP file and the export file of your field group?


  • How do I share an export file from a field group? Can I share the files privately?

  • Hi @lcg_1111

    Yes, you can add it as attachments by clicking the round link button on the left. After that, you can set the visibility to private.


  • Sorry I didn’t write that as clearly as I meant to. How do I export a file from a field group?

  • Hi @lcg_1111

    If you use the PRO version, you can do it from “Custom Fields > Tools”. Just select the field group you want and then click “Download Export File”.

    If you use the free version, you can go to “Custom Fields > Export” and then select the field group you want and then click “Export to XML”.

    Don’t forget to share the PHP where you wrote the code too.


Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Trouble with Image Object vs Image URL’ is closed to new replies.