Showing a Thickbox (tb_show) does nothing
Question
I'm trying to add a media uploader to a widget/plugin and I'm at the stage where I need to add a picture from the media library (or upload a new one).
I added some javascript and added an event to a button in the plugin. This event gets fired (because the alert is displayed), but the thickbox does not show up.
Here's the JS code:
jQuery(document).ready(function() {
jQuery('.upload_image_button').click(function() {
alert('This alert is displayed');
tb_show('Upload a Image', 'media-upload.php&type=image&TB_iframe=true', false);
return false;
});
});
Why isn't the Thickbox displayed?
WordPress version 4.1.1
Solution
Answer can be found here: https://stackoverflow.com/questions/13863087/wordpress-custom-widget-image-upload
Even though the problem described isn't exactly the same as I had, the code posted in the answer still helped me as that code actually does exactly what I needed.
I also think that I didn't originally find this answer as it's on the regular Stack Overflow and not the Wordpress part of it.