REST API: Restore wp-admin/includes/image.php requirement in WP_REST_Attachments_Controller::create_item().

Although the file is already included via the `::insert_attachment()` method, this addresses an inconsistency and corrects a misleading comment.

It also reduces the possibility of a future error in case `::insert_attachment()` is no longer called earlier in `::create_item()` at some point.

Follow-up to [43850] and [44206].

Props luisrivera.
Fixes #49449.

git-svn-id: https://develop.svn.wordpress.org/trunk@47296 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-02-17 03:22:43 +00:00
parent f8d1664544
commit 2d9f3a1330

View File

@ -185,8 +185,9 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
}
// Include media functions to get access to wp_generate_attachment_metadata().
// Include media and image functions to get access to wp_generate_attachment_metadata().
require_once ABSPATH . 'wp-admin/includes/media.php';
require_once ABSPATH . 'wp-admin/includes/image.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.