尝试使用此代码:
define("ME_URL", rtrim(WP_PLUGIN_URL,\'/\') . \'/\' . basename(dirname(__FILE__)));
define("ME_DIR", rtrim(dirname(__FILE__), \'/\'));
function my_admin_scripts() {
wp_enqueue_script(\'media-upload\');
wp_enqueue_script(\'thickbox\');
}
function my_admin_styles() {
wp_enqueue_style(\'thickbox\');
}
add_action(\'admin_print_scripts\', \'my_admin_scripts\');
add_action(\'admin_print_styles\', \'my_admin_styles\');
<td>
<img src="<?php echo esc_attr( get_the_author_meta( \'profileimage\', $user->ID ) ); ?>" id="ppimage">
<input type="text" name="profileimage" id="profileimagetxt" value="<?php echo esc_attr( get_the_author_meta( \'profileimage\', $user->ID ) ); ?>" class="regular-text" /><br />
<input type="button" id="profileimage" value="Upload Image">
<span class="description"><?php _e("profileimage"); ?></span>
</td>
</tr>
<script type="text/javascript">
$ = jQuery.noConflict();
$(document).ready(function($){
$(\'#profileimage\').live(\'click\',function() {
formfield = $(\'#upload_image\').attr(\'name\');
tb_show(\'\', \'media-upload.php?type=image&TB_iframe=true\');
return false;
});
window.send_to_editor = function(html) {
imgurl = $(\'img\',html).attr(\'src\');
$(\'#profileimagetxt\').val(imgurl);
$(\'#ppimage\').attr(\'src\',imgurl);
tb_remove();
}
});
</script>
希望对您有用:)