Title: WP_REST_Attachments_Controller::get_edit_media_item_args
Published: August 11, 2020
Last modified: August 20, 2026

---

# WP_REST_Attachments_Controller::get_edit_media_item_args(): array

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#wp--skip-link--target)

Gets the request args for the edit item route.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#return)󠁿

 array

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#source)󠁿

    ```php
    protected function get_edit_media_item_args() {
    	$args = array(
    		'src'       => array(
    			'description' => __( 'URL to the edited image file.' ),
    			'type'        => 'string',
    			'format'      => 'uri',
    			'required'    => true,
    		),
    		// The `modifiers` param takes precedence over the older format.
    		'modifiers' => array(
    			'description' => __( 'Array of image edits.' ),
    			'type'        => 'array',
    			'minItems'    => 1,
    			'items'       => array(
    				'description' => __( 'Image edit.' ),
    				'type'        => 'object',
    				'required'    => array(
    					'type',
    					'args',
    				),
    				'oneOf'       => array(
    					array(
    						'title'      => __( 'Flip' ),
    						'properties' => array(
    							'type' => array(
    								'description' => __( 'Flip type.' ),
    								'type'        => 'string',
    								'enum'        => array( 'flip' ),
    							),
    							'args' => array(
    								'description' => __( 'Flip arguments.' ),
    								'type'        => 'object',
    								'required'    => array(
    									'flip',
    								),
    								'properties'  => array(
    									'flip' => array(
    										'description' => __( 'Flip direction.' ),
    										'type'        => 'object',
    										'required'    => array(
    											'horizontal',
    											'vertical',
    										),
    										'properties'  => array(
    											'horizontal' => array(
    												'description' => __( 'Whether to flip in the horizontal direction.' ),
    												'type' => 'boolean',
    											),
    											'vertical' => array(
    												'description' => __( 'Whether to flip in the vertical direction.' ),
    												'type' => 'boolean',
    											),
    										),
    									),
    								),
    							),
    						),
    					),
    					array(
    						'title'      => __( 'Rotation' ),
    						'properties' => array(
    							'type' => array(
    								'description' => __( 'Rotation type.' ),
    								'type'        => 'string',
    								'enum'        => array( 'rotate' ),
    							),
    							'args' => array(
    								'description' => __( 'Rotation arguments.' ),
    								'type'        => 'object',
    								'required'    => array(
    									'angle',
    								),
    								'properties'  => array(
    									'angle' => array(
    										'description' => __( 'Angle to rotate clockwise in degrees.' ),
    										'type'        => 'number',
    									),
    								),
    							),
    						),
    					),
    					array(
    						'title'      => __( 'Crop' ),
    						'properties' => array(
    							'type' => array(
    								'description' => __( 'Crop type.' ),
    								'type'        => 'string',
    								'enum'        => array( 'crop' ),
    							),
    							'args' => array(
    								'description' => __( 'Crop arguments.' ),
    								'type'        => 'object',
    								'required'    => array(
    									'left',
    									'top',
    									'width',
    									'height',
    								),
    								'properties'  => array(
    									'left'   => array(
    										'description' => __( 'Horizontal position from the left to begin the crop as a percentage of the image width.' ),
    										'type'        => 'number',
    									),
    									'top'    => array(
    										'description' => __( 'Vertical position from the top to begin the crop as a percentage of the image height.' ),
    										'type'        => 'number',
    									),
    									'width'  => array(
    										'description' => __( 'Width of the crop as a percentage of the image width.' ),
    										'type'        => 'number',
    									),
    									'height' => array(
    										'description' => __( 'Height of the crop as a percentage of the image height.' ),
    										'type'        => 'number',
    									),
    								),
    							),
    						),
    					),
    				),
    			),
    		),
    		'rotation'  => array(
    			'description'      => __( 'The amount to rotate the image clockwise in degrees. DEPRECATED: Use `modifiers` instead.' ),
    			'type'             => 'integer',
    			'minimum'          => 0,
    			'exclusiveMinimum' => true,
    			'maximum'          => 360,
    			'exclusiveMaximum' => true,
    		),
    		'x'         => array(
    			'description' => __( 'As a percentage of the image, the x position to start the crop from. DEPRECATED: Use `modifiers` instead.' ),
    			'type'        => 'number',
    			'minimum'     => 0,
    			'maximum'     => 100,
    		),
    		'y'         => array(
    			'description' => __( 'As a percentage of the image, the y position to start the crop from. DEPRECATED: Use `modifiers` instead.' ),
    			'type'        => 'number',
    			'minimum'     => 0,
    			'maximum'     => 100,
    		),
    		'width'     => array(
    			'description' => __( 'As a percentage of the image, the width to crop the image to. DEPRECATED: Use `modifiers` instead.' ),
    			'type'        => 'number',
    			'minimum'     => 0,
    			'maximum'     => 100,
    		),
    		'height'    => array(
    			'description' => __( 'As a percentage of the image, the height to crop the image to. DEPRECATED: Use `modifiers` instead.' ),
    			'type'        => 'number',
    			'minimum'     => 0,
    			'maximum'     => 100,
    		),
    	);

    	/*
    	 * Get the args based on the post schema. This calls `rest_get_endpoint_args_for_schema()`,
    	 * which also takes care of sanitization and validation.
    	 */
    	$update_item_args = $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE );

    	if ( isset( $update_item_args['caption'] ) ) {
    		$args['caption'] = $update_item_args['caption'];
    	}

    	if ( isset( $update_item_args['description'] ) ) {
    		$args['description'] = $update_item_args['description'];
    	}

    	if ( isset( $update_item_args['title'] ) ) {
    		$args['title'] = $update_item_args['title'];
    	}

    	if ( isset( $update_item_args['post'] ) ) {
    		$args['post'] = $update_item_args['post'];
    	}

    	if ( isset( $update_item_args['alt_text'] ) ) {
    		$args['alt_text'] = $update_item_args['alt_text'];
    	}

    	return $args;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php#L2269)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php#L2269-L2452)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_REST_Attachments_Controller::get_endpoint_args_for_item_schema()](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_endpoint_args_for_item_schema/)`wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php` |

Retrieves the query params for the attachments collection.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

| Used by | Description | 
| [WP_REST_Attachments_Controller::register_routes()](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/register_routes/)`wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php` |

Registers the routes for attachments.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_attachments_controller/get_edit_media_item_args/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Adds flips capability and editable fields for the newly-created attachment post. | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_attachments_controller%2Fget_edit_media_item_args%2F)
before being able to contribute a note or feedback.