Support

Account

Home Forums General Issues Add image url to custom_fields data field

Solving

Add image url to custom_fields data field

  • Hi all

    I want to store the image URL in the custom_fields set. I’m grabbing post data with JSON so don’t have the ability to get the image by URL.

    Is there a filter available to insert the image URL rather than ID? …or ideally both.

    I looked through the docs but don’t see how to do this.

    Any help appreciated
    Rob

  • If the field is an image field then the only way that ACF stores the value is using the ID.

    When you say that you are grabbing the post data with JSON, can you be more specific? I’m not sure what you mean here. Can you supply code that shows the process you’re using to get the data?

  • Hey @hube2 – I’m using a JSON API for WP. It generates a JSON object of a post, including all custom fields.

    Ref : https://wordpress.org/plugins/json-api/

    Anyway, I should have updated my answer to say I managed to use the IDs to navigate back up the attachment array and get the images that way (which is probably the way you would suggest?)

    Thanks 🙂
    Rob

  • I’ve not had experience with that plugin or using it, so to be honest I’m not sure where I’d start. Probably would have tried to figure out it it let me get an the data for an attachment and then done what us suggest, navigate the array in JavaScript to find the id and make another request.

    I’m glad to know you found a solution.

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

The topic ‘Add image url to custom_fields data field’ is closed to new replies.