Home Forums Add-ons Gallery Field Gallery field return images IDs Reply To: Gallery field return images IDs

  • I had a similar issue where ID’s were being returned even though the field was set to return image arrays.

    The problem was that I was importing content from another site and inserting an array of ID’s into the postmeta table with the key set to the field name as I had see it stored for other fields.
    (I’m guessing this is similar to the last post which mentions an API).

    Once imported the galleries showed normally in the admin area so I started working on the frontend and coded for what got returned, which was ID’s.
    I found that when I made a change to the post, the field then returned an array of images so my code stopped working.

    You need 2 meta fields for the gallery to return an array of images.
    The first one matching the field name which contains an array of image id’s and another with the same key starting with an underscore which references the ACF field ID.

    So in my case I have 1 field:
    sth_additional_images => {array of image ID’s}
    and a second:
    _sth_additional_images => field_5eb0a90d770ad

    So I adjusted the import to insert the second field at the same time, ran it again and then the gallery fields worked as expected.