I tried the CMB2 plugin together with my plugin (both versions, 1.0.5 and 1.0.6). I added a File type field to pages:
add_action( 'cmb2_admin_init', 'cmb2_add_metabox' );
function cmb2_add_metabox() {
$prefix = 'yourprefix_demo_';
$cmb_demo = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => esc_html__( 'Test Metabox', 'cmb2' ),
'object_types' => array( 'page' ),
) );
$cmb_demo->add_field( array(
'name' => esc_html__( 'Test Image', 'cmb2' ),
'desc' => esc_html__( 'Upload an image or enter a URL.', 'cmb2' ),
'id' => $prefix . 'image',
'type' => 'file',
) );
}
With either 1.0.5 or 1.0.6, I only get a Month dropdown and no “Uploaded to this post” dropdown in the media modal. With 1.0.5, the media modal doesn’t show any images, and with 1.0.6, the media modal show all images uploaded to the site.
I’m a bit lost with this. How do you get a “Uploaded to this post” dropdown with 1.0.5? Do you need to add a parameter to the $cmb->add_field
function? Do you get any JavaScript error in your browser console with 1.0.6?
-
This reply was modified 8 years ago by
leemon.