File field fails to save in Block Editor
-
Hello!
I’m not really sure how much support you’re giving for CMB2 in the block editor, but I just wanted to let you know that when I added a ‘File’ field with this code:
$post_mb->add_field( array( 'name' => 'Banner Image', 'desc' => 'Upload an image to be used as a banner, 'id' => 'post_banner', 'type' => 'file', // Optional: 'options' => array( 'url' => false, // Hide the text input for the url ), 'text' => array( 'add_upload_file_text' => 'Add File' // Change upload button text. Default: "Add or Upload File" ), // query_args are passed to wp.media's library query. 'query_args' => array( 'type' => array( 'image/jpeg', 'image/png', ), ), 'preview_size' => 'large', // Image size to use when previewing in the admin ) );
The field rendered in its metabox but when a file was selected it didn’t seem to save it. It didn’t show a preview either and when I checked the database it did not add its corresponding post meta.
Hope it helps, cmb2 has been a great lifesaver for me!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘File field fails to save in Block Editor’ is closed to new replies.