Maybe I am thinking about this incorrectly… but… it seems to me that the caption *should* stay with the image, and *not* the post, yeah?
What if you un-attach the image from the post, then the Caption remains, right?
Wait.. now that I typed that out… I suppose what can be done is…
1) Create an ACF field attached to Images…
2) Make it read only (i.e. disable it using the acf/prepare_field filter). That way.. it *stays* with the image, but cannot be edited by anyone.
Now… when you attach that same image to another Post… the data will carry over and stay consistent.
This is the first time hearing of IPTC for me, but here are docs on how to parse the data with PHP.
To attach the field to Images (so that it can be edited in the Media Library), choose ” ‘Attachment’ ‘is equal to’ ‘All image formats’ ” in the Location Rules when creating/editing the ACF Field Group.
Now, I suspect you can use this filter to do you IPTC parsing work, and saving the data into your Custom field. It’s for “saving posts” but can be used for other data types too. I haven’t worked out precisely how to do this final part yet, but I am confident it’s doable. Let me know what you think.
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.