My function looks like this :
function custom_field_template_admin_scripts() {
if ( !defined('WP_PLUGIN_DIR') )
$plugin_dir = str_replace( ABSPATH, '', dirname(__FILE__) );
else
$plugin_dir = dirname( plugin_basename(__FILE__) );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-form' );
wp_enqueue_script( 'date', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/date.js', array('jquery') );
wp_enqueue_script( 'bgiframe', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.bgiframe.js', array('jquery') ) ;
wp_enqueue_script( 'datePicker', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.datePicker.js', array('jquery') );
wp_enqueue_script( 'textarearesizer', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.textarearesizer.js', array('jquery') );
if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || (isset($post) && $post->post_type=='page') ) :
wp_enqueue_script( 'editor' );
//////////////////////////////
//PATCH leup
add_thickbox();
wp_enqueue_script('media-upload');
wp_enqueue_script('jquery-metadata','https://view.jquery.com/trunk/plugins/metadata/jquery.metadata.js',array('jquery'),false,true);
//////////////////////////////
endif;
}
(before or after the last endif is mostly the same. If you put the 3 lines before the last endif allow us to load these scripts only if we are on a edit page…)
With these lines, the media window pops up in a thickbox instead of opening in a new page.
Well, it works for me.