jon-c
1/4/2016 - 11:01 PM

CMB2 File List: Don't show media from other posts. The key is the query_args that tell the media uploader to only show the resources upload

CMB2 File List: Don't show media from other posts.

The key is the query_args that tell the media uploader to only show the resources uploaded to post 99999999999 (which I hope never exists).

$this->cmb_form->add_field( array(
			'name' => 'Resource File List',
			'desc' => '',
			'id'   => $this->cmb_prefix . 'resource_files',
			'type' => 'file_list',
			// 'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
			'attributes' => array(
				'required' => true, // Will be required only if visible.
				'data-conditional-id' => $this->cmb_prefix . 'resource_type',
				'data-conditional-value' => 'files',
			),
			'query_args' => array(
				'uploadedTo' => 99999999999,
			),

		) );