attachment_fields_to_save filter allows you to modify the associated data of an attachment.
It is evaluated in:
wp_ajax_save_attachment_compat()in the wp-admin/includes/ajax-actions.php file
media_upload_form_handler()in the wp-admin/includes/media.php file
edit_post()in the wp-admin/includes/post.php file
attachment_fields_to_save accepts 2 arguments:
$postThe attachment attributes.
$attachment_dataAn array of attachment fields.
The following shows how you might go about saving a custom attachment field — we’ll say, a field with the id of
image_editor_name — implemented via the
View the code example on Gist.Have a suggested improvement? You can fork the Gist and comment back with the link. If all is agreeable, I’ll merge in your changes. Crowd-sourced documentation FTW!