WP_REST_Attachments_Controller::get_collection_params
Retrieves the query params for collections of attachments.
Method of the class: WP_REST_Attachments_Controller{}
No Hooks.
Returns
Array. Query parameters for the attachment collection as an array.
Usage
$WP_REST_Attachments_Controller = new WP_REST_Attachments_Controller(); $WP_REST_Attachments_Controller->get_collection_params();
Changelog
| Since 4.7.0 | Introduced. |
| Since 6.9.0 | Extends the media_type and mime_type request arguments to support array values. |
WP_REST_Attachments_Controller::get_collection_params() WP REST Attachments Controller::get collection params code WP 7.0
public function get_collection_params() {
$params = parent::get_collection_params();
$params['status']['default'] = 'inherit';
$params['status']['items']['enum'] = array( 'inherit', 'private', 'trash' );
$media_types = array_keys( $this->get_media_types() );
$params['media_type'] = array(
'default' => null,
'description' => __( 'Limit result set to attachments of a particular media type or media types.' ),
'type' => 'array',
'items' => array(
'type' => 'string',
'enum' => $media_types,
),
);
$params['mime_type'] = array(
'default' => null,
'description' => __( 'Limit result set to attachments of a particular MIME type or MIME types.' ),
'type' => 'array',
'items' => array(
'type' => 'string',
),
);
return $params;
}