WordPress: wp.media.frame doesn’t display attachment

I am using the wp.media frame uploader in my plugin to upload files. It works perfectly as it should except one problem.
When I upload file (using upload button, or drag and drop) it uploads the file and displays its information in sidebar menu, but doesn’t display thumbnail of attachment. Its a kind of annoying problem because first its a default behaviour on wp.media and second same implementation is working fine on different plugin. Has anyone come across this problem..

Code I used is:

Read More
    var alex_doc_uploader = $thisButton.data('file_frame');
    if (alex_doc_uploader) {
        alex_doc_uploader.open();
        return;
    }

    // Create the media frame.
    alex_doc_uploader = wp.media.frames.file_frame = wp.media({
        title: "Select Documents",
        button: {
            text: "Select Documents"
        },
        library : {
          type:   accepted_mime_types
        },
        multiple: true  // Set to true to allow multiple files to be selected
    });

    $thisButton.data('file_frame', alex_doc_uploader);

And when i upload a file,
enter image description here

The result I get is
enter image description here

But what should happen is
enter image description here

Related posts

1 comment

  1. Figured out the problem.. It was a bug on wordpress till 4.2.2. WordPress can’t support multiple mimetypes provided as type of wp.media. It does support to filter out the content displayed but can’t load on screen if uploaded.
    Here is the issue created on wordpress

    Media Upload mimeType validation bug

    My patch

    hopefully it will be solved in 4.2.3 or 4.3. Or you can do patch with those patches

Comments are closed.