Support » Plugin: CMB2 » File Upload Not Working in WordPress 5.3.2

  • Resolved viastudio

    (@viastudio)


    Tested with CMB2 versions 2.1, 2.6, 2.7
    PHP version: 7.3

    After upgrading WordPress to 5.3.2, clicking the upload button or image on a file field simply doesn’t do anything. Clicking the delete icon on an image returns you to the top of the page editor but doesn’t remove the image.

    These Github issues are related to the same problem, but they were closed without any fix suggestions.

    Here is the setup code:

    
    function add_theme_custom_fields() {
        $prefix = 'li_';
        $page_meta = new_cmb2_box([
            'id' => $prefix . 'page_meta',
            'title' => 'Page Meta',
            'object_types' => ['page'],
            'show_on_cb'    => 'cmb_metabox_include_front_page',
            'context' => 'normal',
            'priority' => 'high'
        ]);
    
        $page_meta->add_field([
            'id'   => $prefix . 'meta_image',
            'name' => 'Image',
            'type'    => 'file',
            'query_args' => array(
                'type' => [
                    'image/jpeg',
                    'image/png',
                ]
            ),
            'row_classes' => 'no-border'
        ]);
    }
    
    function cmb_metabox_include_front_page($cmb) {
        $front_page_id = get_option('page_on_front');
        return $front_page_id == $cmb->object_id;
    }
    

    There are no errors in the browser console or in the server logs. There also aren’t any 404s for the resources; the CMB2 CSS and JS are being loaded. All of the metaboxes and their content are still displaying correctly; the media modal just won’t open for file fields.

    • This topic was modified 2 years, 11 months ago by viastudio.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Gutenberg or Classic editor?

    Thread Starter viastudio

    (@viastudio)

    Classic

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Can you check your browser dev tools console? I’m not managing to recreate any issue with this on even 5.4 beta2. My hunch is that there’s some sort of javascript error in your overall pageload that’s preventing the modal.

    Thread Starter viastudio

    (@viastudio)

    Good call. Caught another error: TypeError: wp.data.select(...) is null and didn’t think about it blocking the CMB2 script. The file upload works after deactivating Yoast. I’ll dig into that error and consider this resolved.

    Thanks!

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Fun times, plugin conflicts!

    Let us know if anything else comes up.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘File Upload Not Working in WordPress 5.3.2’ is closed to new replies.