Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In the past when using thickbox to upload images, an image could be uploaded without having the post ID 'attached' to it by simply using the code below :

jQuery('.upload_slider_button').click(function() {
     tb_show('', 'media-upload.php?post_id=&type=image&TB_iframe=true&referer=matrix-settings');
     return false;
});

However, how can I achieve the same thing using the new Media Uploader which was introduced since WP3.5? I have spent the whole day searching in the internet but there isn't much resources available on this new media uploader. Most of it are focused on utilizing it in theme options / plugins.

Or perhaps there are other ways of uploading an image without having the post ID 'attached' to it and yet not using any plugins?

Thanks a lot for helping.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.