Support

Account

Home Forums General Issues JSON Custom Field for IMG – ID only?

Solved

JSON Custom Field for IMG – ID only?

  • When using a plugin such as https://wordpress.org/plugins/json-api/ it returns custom fields in JSON which is great. The problem is, it returns the Image as an ID, which is not helpful. For example:

    list_0_image": [
        "98"
    ]

    I tried setting the type in the ACF admin from image array to image url (not image id) but it only seems to affect the php area, not what’s getting returned in the custom field JSON.

    I feel as though this may be a bug? or is there a work around to fixing this?

  • Hi @zurnet

    ACF saves the image ID in the database. If you want to show the image URL, please ask the JSON API plugin author if they have a hook to modify the returned data.

    I hope this makes sense.

  • I see why it’s saving the ID, but yes… went in and modified the plugin to accommodate this. It involves using:

    wp_get_attachment_image_src();

    passing in the ID of the image, so you can then retrieve the URL of the image

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

The topic ‘JSON Custom Field for IMG – ID only?’ is closed to new replies.