Custom Fields
Re-Envisioned
Support MB REST API “Image Advanced” field doesn’t save full image details to REST API

  • Creator
    Topic
  • #19313
    Resolved Amanda
    Participant

    When I look up my “Image Advanced” field data via REST API, I only get the image ID (as if “Image Advanced” was a regular “Image” field). Looks like this:

    "image_url":["3344"]

    I’m not getting the full “Image Advanced” image data (like image URL).

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #19314
    Amanda
    Participant

    It seems like this error only occurs when the “Image Advanced” field is put inside a Group.

    #19324
    Long Nguyen
    Moderator

    Hi,

    If the field is nested in a group, it will be serialized and saved in the database such as {"image_advanced":["1957","1956","1955"]}. For some special fields, only the ID will be saved and you need to use some helper functions to get the URL of the image by the ID. For more information, please follow this documentation
    https://docs.metabox.io/extensions/meta-box-group/#special-fields

    #19325
    Anh Tran
    Keymaster

    Hi Amanda,

    That’s right. For groups, the data is sent as raw, similarly to what you get via the helper function.

    #19346
    Amanda
    Participant

    Got it! Why is it set up this way? I need to make a ton of calls to the REST API to grab metabox data, including image URLs, so I can display the content elsewhere (not on wordpress). I want to avoid making all those extra calls to the REST API (to /wp-json/wp/v2/media/{id}) to fetch the full image URLs. Is there a way I can edit one of the metabox plugins to add the full url field to Image Advanced (whether it’s nested in a group or not)? Or is there no way to make this work when Image Advanced is nested in a group?

    #19353
    Long Nguyen
    Moderator

    Hi,

    It’s the feature of Group field Database optimization of sub-fields for reduced bloat. If every field nested in Group has all property saved, it will increase the size of the database and slow down your site. That’s why Group only saves necessary information of the sub-field.

    Hope that makes sense.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash