Advanced Custom Fields
Retuning the ID of the image instead of the url (3 posts)

  1. mrbrand
    Posted 4 years ago #

    I create a new custom field,
    type: image
    return value: image url,

    I post new entry and add image with add button

    Problem: the custome field gets the image attachment ID, not URL


  2. shel.80
    Posted 4 years ago #

    Hi mrbrand. I got stuck on this just now and found the answer:

    Let's say your field is named additional_image, then you'd use this code in your template:

    <img src="<?php the_field('additional_image'); ?>" alt="blah blah blah" />

    That would generate the url of the image and thus show up.

    More details here:


    Hope that helps!

  3. shel.80
    Posted 4 years ago #

    Just to add, even though you have selected image url as return value the custom field with still produce the attachment id number as the value (which is what puzzled me at first), but the code behind "the_field" function will allow it to get the url information.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic