CMB2 Rest API – image/file field as an object
-
Hello,
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 tofile_list
? Something like this?
{'123': 'https://site.com/wp-content/uploads/image.jpg'}
The page I need help with: [log in to see the link]
- The topic ‘CMB2 Rest API – image/file field as an object’ is closed to new replies.