I played with the new media manager in WordPress and had some fun, but got to the point where I hit my head against the wall.
I have a custom meta box in which I would like to store some images (well, this is hidden input, and I currently store their identifiers, but can equally be image objects), and then makes an AJAX call to show some thumbnails that I subsequently made draggable so that users could reorder (not necessarily matching just some background).
My problem is that when I open the media manager, the images are not selected, so if the user wants to edit the images in his gallery, they need to select them again.
What I'm trying to understand is how to open a media manager with the current images that have passed through them so that they are preselected.
So my code looks like this:
jQuery('#myButton').click(function(e) { e.preventDefault(); frame = wp.media({ title : 'My Gallery Title', multiple : true, library : { type : 'image'}, button : { text : 'Insert' }, }); frame.on('close',function() {
My thought is that there should be either a parameter that needs to be passed to the frame (maybe a JSON object for images, or I need to create an event for
frame.on('open', function() {
But I tried both ways round and I wonβt go anywhere.
It would seem that since changing the "Featured Image" will lead you to the library with the currently selected one - I just could not understand the basic code enough and hope there is someone else!
wordpress media
Mark Dec 18 '12 at 15:22 2012-12-18 15:22
source share