Home Forums General Issues Image URL returns ID and not a string


Image URL returns ID and not a string

  • I have a field set up that’s located in User. It’s a image field that the User can upload and I’m trying to get the URL so I can output it into an img src. I’m using other text fields and I’m capable of pulling those just fine.

    <?php $user_id = get_query_var( 'author' ) ?>
    <?php $clan_member_info = get_userdata($user_id); ?>
    <p><?php if(!empty($clan_member_info->psn_id)) echo '<li>' . $clan_member_info->psn_id . '</li>'; ?></p> //Example of me pulling a text field
    <?php if(!empty($clan_member_info->cover_photo)) echo '<img src="'.$clan_member_info->cover_photo.'"/>'; ?>

    The example of the psn_id pulls perfectly. The img returns this <img src="95">.

    I have the full php file here.

    • James

    • June 9, 2016 at 1:43 pm

    Hi @darrenbachan

    ACF saves the image ID instead of the image URL in the database. Please use the get_field() or the_field() function to get the processed value. This page should give you more idea about it:

    Also, please take a look at this page to learn how to get the value from a user:

    I hope this helps 🙂

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.