Skip to content

Commit

Permalink
Add filter to REST API image edit. (#23539)
Browse files Browse the repository at this point in the history
* Add action to REST API image edit.

* Change param on action.

* Convert to filter.
  • Loading branch information
spacedmonkey authored Jun 28, 2020
1 parent 315707c commit 284683c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/class-wp-rest-image-editor-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ public function apply_edits( $request ) {
'file' => _wp_relative_upload_path( $image_file ),
);

/**
* Filters the updated attachment meta data.
*
* @since 5.5.0
*
* @param array $data Array of updated attachment meta data.
* @param int $new_attachment_id Attachment post ID.
* @param int $attachment_id Original Attachment post ID.
*/
$new_image_meta = apply_filters( 'wp_edited_attachment_metadata', $new_image_meta, $new_attachment_id, $attachment_id );

wp_update_attachment_metadata( $new_attachment_id, $new_image_meta );

$path = '/wp/v2/media/' . $new_attachment_id;
Expand Down

0 comments on commit 284683c

Please sign in to comment.