#32: attachment_fields_to_save

The attachment_fields_to_save filter allows you to modify the associated data of an attachment.

It is evaluated in:

attachment_fields_to_save accepts 2 arguments:

  1. array $post The attachment attributes.
  2. array $attachment_data An array of attachment fields.

Example:

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 attachment_fields_to_edit filter.

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!

Leave a Reply

Your email address will not be published. Required fields are marked *