WP_REST_Attachments_Controller::get_collection_params() WordPress Method

The WP_REST_Attachments_Controller::get_collection_params() method is used to get the collection parameters for the attachments controller. This is used to limit the number of attachments that are returned in a request.

WP_REST_Attachments_Controller::get_collection_params() #

Retrieves the query params for collections of attachments.


Return

(array) Query parameters for the attachment collection as an array.


Top ↑

Source

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

	public function get_collection_params() {
		$params                            = parent::get_collection_params();
		$params['status']['default']       = 'inherit';
		$params['status']['items']['enum'] = array( 'inherit', 'private', 'trash' );
		$media_types                       = $this->get_media_types();

		$params['media_type'] = array(
			'default'     => null,
			'description' => __( 'Limit result set to attachments of a particular media type.' ),
			'type'        => 'string',
			'enum'        => array_keys( $media_types ),
		);

		$params['mime_type'] = array(
			'default'     => null,
			'description' => __( 'Limit result set to attachments of a particular MIME type.' ),
			'type'        => 'string',
		);

		return $params;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.