Summery Summery

Prepares a single attachment for create or update.

Syntax Syntax

WP_REST_Attachments_Controller::prepare_item_for_database( WP_REST_Request $request )

Parameters Parameters


(WP_REST_Request) (Required) Request object.

Return Return

(stdClass|WP_Error) Post object.

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

	 * @since 5.5.0
	 * @param WP_REST_Request $request Full details about the request.
	 * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
	public function edit_media_item_permissions_check( $request ) {
		if ( ! current_user_can( 'upload_files' ) ) {
			return new WP_Error(
				__( 'Sorry, you are not allowed to upload media on this site.' ),
				array( 'status' => rest_authorization_required_code() )

		return $this->update_item_permissions_check( $request );

	 * Applies edits to a media item and creates a new attachment record.
	 * @since 5.5.0
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error Response object on success, WP_Error object on failure.
	public function edit_media_item( $request ) {
		require_once ABSPATH . 'wp-admin/includes/image.php';


Changelog Changelog

Version Description
4.7.0 Introduced.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

What are you looking for?