<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[46422] trunk: REST API: Add support for continuing the post-processing of images after upload.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/46422">46422</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/46422","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-10-07 17:04:49 +0000 (Mon, 07 Oct 2019)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>REST API: Add support for continuing the post-processing of images after upload. Flow:
1. `POST /wp/v2/media`.
2. If the upload failed (HTTP 500 error), look for a response header with `X-WP-Upload-Attachment-ID` header that contains the newly created attachment ID.
3. `POST /wp/v2/media/{id}/post-process` with `{ "action": "create-image-subsizes" }`. This request may still fail, but it will save its progress.
4. On continued failure, `DELETE /wp/v2/media/{id}` to give up on the upload and instruct the user to resize their image before uploading.

Props TimothyBlynJacobs.
Fixes <a href="https://core.trac.wordpress.org/ticket/47987">#47987</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestattachmentscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestattachmentscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestschemasetupphp">trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php</a></li>
<li><a href="#trunktestsqunitfixtureswpapigeneratedjs">trunk/tests/qunit/fixtures/wp-api-generated.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrestapiendpointsclasswprestattachmentscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2019-10-07 15:28:29 UTC (rev 46421)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php   2019-10-07 17:04:49 UTC (rev 46422)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,6 +16,30 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        public function register_routes() {
+               parent::register_routes();
+               register_rest_route(
+                       $this->namespace,
+                       '/' . $this->rest_base . '/(?P<id>[\d]+)/post-process',
+                       array(
+                               'methods'             => WP_REST_Server::CREATABLE,
+                               'callback'            => array( $this, 'post_process_item' ),
+                               'permission_callback' => array( $this, 'post_process_item_permissions_check' ),
+                               'args'                => array(
+                                       'id'     => array(
+                                               'description' => __( 'Unique identifier for the object.' ),
+                                               'type'        => 'integer',
+                                       ),
+                                       'action' => array(
+                                               'type'     => 'string',
+                                               'enum'     => array( 'create-image-subsizes' ),
+                                               'required' => true,
+                                       ),
+                               ),
+                       )
+               );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Determines the allowed query_vars for a get_items() response and
</span><span class="cx" style="display: block; padding: 0 10px">         * prepares for WP_Query.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,6 +124,70 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $insert = $this->insert_attachment( $request );
+
+               if ( is_wp_error( $insert ) ) {
+                       return $insert;
+               }
+
+               // Extract by name.
+               $attachment_id = $insert['attachment_id'];
+               $file          = $insert['file'];
+
+               if ( isset( $request['alt_text'] ) ) {
+                       update_post_meta( $attachment_id, '_wp_attachment_image_alt', sanitize_text_field( $request['alt_text'] ) );
+               }
+
+               $attachment    = get_post( $attachment_id );
+               $fields_update = $this->update_additional_fields_for_object( $attachment, $request );
+
+               if ( is_wp_error( $fields_update ) ) {
+                       return $fields_update;
+               }
+
+               $request->set_param( 'context', 'edit' );
+
+               /**
+                * Fires after a single attachment is completely created or updated via the REST API.
+                *
+                * @since 5.0.0
+                *
+                * @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 );
+
+               if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
+                       // Set a custom header with the attachment_id.
+                       // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
+                       header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
+               }
+
+               // Include admin function to get access to wp_generate_attachment_metadata().
+               require_once ABSPATH . 'wp-admin/includes/media.php';
+
+               // Post-process the upload (create image sub-sizes, make PDF thumbnalis, etc.) and insert attachment meta.
+               // At this point the server may run out of resources and post-processing of uploaded images may fail.
+               wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
+
+               $response = $this->prepare_item_for_response( $attachment, $request );
+               $response = rest_ensure_response( $response );
+               $response->set_status( 201 );
+               $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $attachment_id ) ) );
+
+               return $response;
+       }
+
+       /**
+        * Inserts the attachment post in the database. Does not update the attachment meta.
+        *
+        * @since 5.3.0
+        *
+        * @param WP_REST_Request $request
+        * @return array|WP_Error
+        */
+       protected function insert_attachment( $request ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 // Get the file via $_FILES or raw data.
</span><span class="cx" style="display: block; padding: 0 10px">                $files   = $request->get_file_params();
</span><span class="cx" style="display: block; padding: 0 10px">                $headers = $request->get_headers();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -138,7 +226,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $attachment                 = $this->prepare_item_for_database( $request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $attachment = $this->prepare_item_for_database( $request );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $attachment->post_mime_type = $type;
</span><span class="cx" style="display: block; padding: 0 10px">                $attachment->guid           = $url;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,6 +244,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        } else {
</span><span class="cx" style="display: block; padding: 0 10px">                                $id->add_data( array( 'status' => 400 ) );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">                         return $id;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,40 +262,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                do_action( 'rest_insert_attachment', $attachment, $request, true );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Include admin function to get access to wp_generate_attachment_metadata().
-               require_once ABSPATH . 'wp-admin/includes/media.php';
-
-               wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
-
-               if ( isset( $request['alt_text'] ) ) {
-                       update_post_meta( $id, '_wp_attachment_image_alt', sanitize_text_field( $request['alt_text'] ) );
-               }
-
-               $fields_update = $this->update_additional_fields_for_object( $attachment, $request );
-
-               if ( is_wp_error( $fields_update ) ) {
-                       return $fields_update;
-               }
-
-               $request->set_param( 'context', 'edit' );
-
-               /**
-                * Fires after a single attachment is completely created or updated via the REST API.
-                *
-                * @since 5.0.0
-                *
-                * @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 );
-
-               $response = $this->prepare_item_for_response( $attachment, $request );
-               $response = rest_ensure_response( $response );
-               $response->set_status( 201 );
-               $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $id ) ) );
-
-               return $response;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return array(
+                       'attachment_id' => $id,
+                       'file'          => $file,
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -254,6 +314,39 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Performs post processing on an attachment.
+        *
+        * @since 5.3.0
+        *
+        * @param WP_REST_Request $request
+        * @return WP_REST_Response|WP_Error
+        */
+       public function post_process_item( $request ) {
+               switch ( $request['action'] ) {
+                       case 'create-image-subsizes':
+                               require_once ABSPATH . 'wp-admin/includes/image.php';
+                               wp_update_image_subsizes( $request['id'] );
+                               break;
+               }
+
+               $request['context'] = 'edit';
+
+               return $this->prepare_item_for_response( get_post( $request['id'] ), $request );
+       }
+
+       /**
+        * Checks if a given request can perform post processing on an attachment.
+        *
+        * @sicne 5.3.0
+        *
+        * @param WP_REST_Request $request Full details about the request.
+        * @return true|WP_Error True if the request has access to update the item, WP_Error object otherwise.
+        */
+       public function post_process_item_permissions_check( $request ) {
+               return $this->update_item_permissions_check( $request );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Prepares a single attachment for create or update.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 4.7.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -380,6 +473,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $data['source_url'] = wp_get_attachment_url( $post->ID );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( in_array( 'missing_image_sizes', $fields, true ) ) {
+                       require_once ABSPATH . 'wp-admin/includes/image.php';
+                       $data['missing_image_sizes'] = array_keys( wp_get_missing_image_subsizes( $post->ID ) );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $data = $this->filter_response_by_context( $data, $context );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -514,6 +612,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'readonly'    => true,
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $schema['properties']['missing_image_sizes'] = array(
+                       'description' => __( 'List of the missing image sizes of the attachment.' ),
+                       'type'        => 'array',
+                       'items'       => array( 'type' => 'string' ),
+                       'context'     => array( 'edit' ),
+                       'readonly'    => true,
+               );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 unset( $schema['properties']['password'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->schema = $schema;
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestattachmentscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php        2019-10-07 15:28:29 UTC (rev 46421)
+++ trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php  2019-10-07 17:04:49 UTC (rev 46422)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1327,7 +1327,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $response   = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">                $data       = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px">                $properties = $data['schema']['properties'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( 26, count( $properties ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( 27, count( $properties ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertArrayHasKey( 'author', $properties );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'alt_text', $properties );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'caption', $properties );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1360,6 +1360,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'raw', $properties['title']['properties'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'rendered', $properties['title']['properties'] );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'type', $properties );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->assertArrayHasKey( 'missing_image_sizes', $properties );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_additional_field_registration() {
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestschemasetupphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php  2019-10-07 15:28:29 UTC (rev 46421)
+++ trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php    2019-10-07 17:04:49 UTC (rev 46422)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,6 +99,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp/v2/pages/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp/v2/media',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp/v2/media/(?P<id>[\\d]+)',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '/wp/v2/media/(?P<id>[\\d]+)/post-process',
</ins><span class="cx" style="display: block; padding: 0 10px">                         '/wp/v2/blocks',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp/v2/blocks/(?P<id>[\d]+)',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/wp/v2/blocks/(?P<id>[\d]+)/autosaves',
</span></span></pre></div>
<a id="trunktestsqunitfixtureswpapigeneratedjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/fixtures/wp-api-generated.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/fixtures/wp-api-generated.js    2019-10-07 15:28:29 UTC (rev 46421)
+++ trunk/tests/qunit/fixtures/wp-api-generated.js      2019-10-07 17:04:49 UTC (rev 46422)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2304,6 +2304,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">             ]
</span><span class="cx" style="display: block; padding: 0 10px">         },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        "/wp/v2/media/(?P<id>[\\d+])/post-process": {
+            "namespace": "wp/v2",
+            "methods": [
+                "POST"
+            ],
+            "endpoints": [
+                {
+                    "methods": [
+                        "POST"
+                    ],
+                    "args": {
+                        "id": {
+                            "required": false,
+                            "description": "Unique identifier for the object.",
+                            "type": "integer"
+                        },
+                        "action": {
+                            "required": true,
+                            "enum": [
+                                "create-image-subsizes"
+                            ],
+                            "type": "string"
+                        }
+                    }
+                }
+            ]
+        },
</ins><span class="cx" style="display: block; padding: 0 10px">         "/wp/v2/blocks": {
</span><span class="cx" style="display: block; padding: 0 10px">             "namespace": "wp/v2",
</span><span class="cx" style="display: block; padding: 0 10px">             "methods": [
</span></span></pre>
</div>
</div>

</body>
</html>