delete_attachment action-hookWP 2.0.0

Usage

add_action( 'delete_attachment', 'wp_kama_delete_attachment_action', 10, 2 );

/**
 * Function for `delete_attachment` action-hook.
 * 
 * @param int     $post_id Attachment ID.
 * @param WP_Post $post    Post object.
 *
 * @return void
 */
function wp_kama_delete_attachment_action( $post_id, $post ){

	// action...
}
$post_id(int)
Attachment ID.
$post(WP_Post)
Post object.

Changelog

Since 2.0.0 Introduced.
Since 5.5.0 Added the $post parameter.

Where the hook is called

wp_delete_attachment()
delete_attachment
wp-includes/post.php 6376
do_action( 'delete_attachment', $post_id, $post );

Where the hook is used in WordPress

wp-admin/includes/class-wp-site-icon.php 72
add_action( 'delete_attachment', array( $this, 'delete_attachment_data' ) );
wp-includes/default-filters.php 523
add_action( 'delete_attachment', '_delete_attachment_theme_mod' );