Is there a way to make sure the “Media Library” tab does not show any images until I start uploading some in the “Upload Files” tab?
I am creating a wp.media frame with the following code:
var myframe = wp.media({
title : 'Bla Bla',
frame : 'select',
library: {
//query : false, // not working
type : 'image',
},
//library : '', // not working either
multiple : true,
button : { text : 'Finish' },
});
It creates this:
Is there a way to make sure the “Media Library” tab does not show any images until I start uploading some in the “Upload Files” tab? And then obviously only shows those images that I just uploaded from the “Upload Images” tab.
It’s not a pretty solution but I used the post__in attribute for this once in a custom plugin. Basically you usually define an array of attachment id’s to show in the media library.
My code was originally built for that at that time. This was great for posts where the attachments were already attached to the post. But then I needed to show nothing for new posts. And what happened was that if the javascript variable containing the id’s was empty it would show the entire contents of the media library instead.
I figured I could try using a hardcoded id which certainly had no attachment associated with it. So I did this:
And by God, it worked. I hope it does for you aswell.