wp_insert_attachment_data filter-hookWP 3.9.0

Filters attachment post data before it is updated in or added to the database.

Usage

add_filter( 'wp_insert_attachment_data', 'wp_kama_insert_attachment_data_filter', 10, 4 );

/**
 * Function for `wp_insert_attachment_data` filter-hook.
 * 
 * @param array $data                An array of slashed, sanitized, and processed attachment post data.
 * @param array $postarr             An array of slashed and sanitized attachment post data, but not processed.
 * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed attachment post data as originally passed to wp_insert_post().
 * @param bool  $update              Whether this is an existing attachment post being updated.
 *
 * @return array
 */
function wp_kama_insert_attachment_data_filter( $data, $postarr, $unsanitized_postarr, $update ){

	// filter...
	return $data;
}
$data(array)
An array of slashed, sanitized, and processed attachment post data.
$postarr(array)
An array of slashed and sanitized attachment post data, but not processed.
$unsanitized_postarr(array)
An array of slashed yet unsanitized and unprocessed attachment post data as originally passed to wp_insert_post().
$update(true|false)
Whether this is an existing attachment post being updated.

Changelog

Since 3.9.0 Introduced.
Since 5.4.1 The $unsanitized_postarr parameter was added.
Since 6.0.0 The $update parameter was added.

Where the hook is called

wp_insert_post()
wp_insert_attachment_data
wp-includes/post.php 4446
$data = apply_filters( 'wp_insert_attachment_data', $data, $postarr, $unsanitized_postarr, $update );

Where the hook is used in WordPress

Usage not found.