I am using the attachment_fields_to_edit filter to add additional fields to the image detail box (seen when you click an image from the gallery field type).
The fields are showing up as expected, however any changes to the fields are not properly saved to the post meta.
Looking through the code for the gallery field, I see there is a function called “ajax_update_attachment” which specifically only looks for the hardcoded fields: title, caption, description, alt.
This function needs to be updated to check the filter attachment_fields_to_save so that any user defined fields are updated properly.
Any update on this?
These custom attachment meta fields are being displayed properly (line #357 of /pro/fields/gallery.php)
However without the fix I outlined above, changes to custom meta fields are never saved to the database.
If ACF isn’t going to properly save the data from these fields, then they shouldn’t be displayed to begin with. But obviously the better solution is simply to call the ‘attachment_fields_to_save’ filter as I outlined above.
I have this working on a project however until this fix gets included into ACF it will be overwritten with every new update.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.