How to upload image without post ID using the new media uploader?

Well, I have finally figured it out. Using Mike’s example here, I just need to put this code wp.media.model.settings.post.id = 0 at this place :

event.preventDefault();

    wp.media.model.settings.post.id = 0;

    // If the media frame already exists, reopen it.
    if ( file_frame ) {
        file_frame.open();
        return;
    }

This will cause the image to be uploaded as ‘Unattached’. Hope this helps someone facing this problem in the future.

Leave a Comment