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.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

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:3892wp_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.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

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

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 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.