wppaste
WordPress

do_action( 'wp_media_attach_action', string $action, int $attachment_id, int $parent_id )

Since
5.5.0
Fires when media is attached or detached from a post.

Compatibility

WordPress
since 5.5.0
  • 6.7.10
  • 6.8.11
  • 6.9.10
  • 7.0.7
  • 7.1.3

Present in every tracked release (6.7.10 to 7.1.3).

Parameters

$actionstring
Attach/detach action. Accepts 'attach' or 'detach'.
$attachment_idint
The attachment ID.
$parent_idint
Attachment parent ID.

Where this hook fires · 1

  • wp-admin/includes/media.php:3870wp_media_attach_action()

Source code

			 * @since 5.5.0			 *			 * @param string $action        Attach/detach action. Accepts 'attach' or 'detach'.			 * @param int    $attachment_id The attachment ID.			 * @param int    $parent_id     Attachment parent ID.			 */			do_action( 'wp_media_attach_action', $action, $attachment_id, $parent_id ); 			clean_attachment_cache( $attachment_id );		} 		$location = 'upload.php';		$referer  = wp_get_referer();

Changelog

Introduced in 5.5.0. Unchanged from 6.7.10 through 7.1.3.

  1. 6.7.10
  2. 6.8.11
  3. 6.9.10
  4. 7.0.7
  5. 7.1.3

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.11 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.