rest_after_insert_attachment

rest_after_insert_attachment

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: wordpress-6.7.2

do_action('rest_after_insert_attachment') is found 2 times:

  • /wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php line 214
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    * @param WP_Post         $attachment Inserted or updated attachment object.
     * @param WP_REST_Request $request    Request object.
     * @param bool            $creating   True when creating an attachment, false when updating.
     */
    do_action( 'rest_after_insert_attachment', $attachment, $request, true );
     
    wp_after_insert_post( $attachment, false, null );
     
    if ( wp_is_serving_rest_request() ) {
        /*
         * Set a custom header with the attachment_id.
  • /wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php line 441
    438
    439
    440
    441
    442
    443
    444
    445
    446
    $request->set_param( 'context', 'edit' );
     
    /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */
    do_action( 'rest_after_insert_attachment', $attachment, $request, false );
     
    wp_after_insert_post( $attachment, true, $attachment_before );
     
    $response = $this->prepare_item_for_response( $attachment, $request );
    $response = rest_ensure_response( $response );

See this hook used in plugins: