Support » Plugin: CMB2 » CMB2 Rest API – image/file field as an object

  • Resolved petefuseloft



    I’m using the REST API from CMB2 to build out a headless CMS/static site, and I’m running into an issue I can’t find away around:

    The file_list field type returns an object of key/value pairs with the ID of the image as the key. This enables me to hit the wordpress REST API and retrieve each image’s data (alt_text, width, height, etc).

    However, the file field type only returns a string. That’s useful for just displaying the image, but it would be way more useful to also be able to access that file as an object. I can’t think of a way to do this without having the ID.

    Is there any way to have the file field output be similar to file_list? Something like this?
    {'123': ''}

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.