Thank you for taking a look into this! I had suspected that I should be focusing solely on WP hooks for this, and I have also been unsuccessful at finding the right one.
Since there doesn’t seem to be anything identifiable about a specific “Add Media” button, I should find a hook where the
$_SERVER['HTTP_REFERER'] will point to the form’s page plus where I can access the attachment’s ID after it has been uploaded.
I’ve tried the ‘add_attachment‘ action but the referer is always media-new.php, then the ‘wp_handle_upload‘ filter doesn’t seem to provide a way to access the attachment’s ID, and ‘wp_handle_upload_prefilter‘ fires before the upload happens so no luck…
P.S.: Also many thanks for the aforementioned Image field solution. It was very useful for my projects.
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!