wp_media_attach_action action-hookWP 5.5.0

Fires when media is attached or detached from a post.

Usage

add_action( 'wp_media_attach_action', 'wp_kama_media_attach_action', 10, 3 );

/**
 * Function for `wp_media_attach_action` action-hook.
 * 
 * @param string $action        Attach/detach action. Accepts 'attach' or 'detach'.
 * @param int    $attachment_id The attachment ID.
 * @param int    $parent_id     Attachment parent ID.
 *
 * @return void
 */
function wp_kama_media_attach_action( $action, $attachment_id, $parent_id ){

	// action...
}
$action(string)
Attach/detach action. Accepts 'attach' or 'detach'.
$attachment_id(int)
The attachment ID.
$parent_id(int)
Attachment parent ID.

Changelog

Since 5.5.0 Introduced.

Where the hook is called

wp_media_attach_action()
wp_media_attach_action
wp-admin/includes/media.php 3853
do_action( 'wp_media_attach_action', $action, $attachment_id, $parent_id );

Where the hook is used in WordPress

Usage not found.