protected function prepare_item_for_database( $request ) {
		$prepared_attachment = parent::prepare_item_for_database( $request );

		if ( isset( $request['caption'] ) ) {
			$prepared_attachment->post_excerpt = $request['caption'];
		}

		if ( isset( $request['description'] ) ) {
			$prepared_attachment->post_content = $request['description'];
		}

		if ( isset( $request['post'] ) ) {
			$prepared_attachment->post_parent = (int) $request['post'];
		}

		return $prepared_attachment;
	}
protected function prepare_item_for_database( $request ) {
		$prepared_attachment = parent::prepare_item_for_database( $request );

		if ( isset( $request['caption'] ) ) {
			$prepared_attachment->post_excerpt = $request['caption'];
		}

		if ( isset( $request['description'] ) ) {
			$prepared_attachment->post_content = $request['description'];
		}

		if ( isset( $request['post'] ) ) {
			$prepared_attachment->post_parent = (int) $request['post'];
		}

		return $prepared_attachment;
	}
protected function prepare_item_for_database ( $ request ) { $ prepared_attachment = parent :: prepare_item_for_database ( $ request ) ; if ( isset ( $ request [ 'caption' ] ) ) { $ prepared_attachment -> post_excerpt = $ request [ 'caption' ] ; } if ( isset ( $ request [ 'description' ] ) ) { $ prepared_attachment -> post_content = $ request [ 'description' ] ; } if ( isset ( $ request [ 'post' ] ) ) { $ prepared_attachment -> post_parent = ( int ) $ request [ 'post' ] ; } return $ prepared_attachment ; }
Prepare a single attachment for create or update.

@param WP_REST_Request $request Request object.
@return WP_Error|stdClass $prepared_attachment Post object.
Prepare a single attachment for create or update .