<?php wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_script('my-upload'); wp_enqueue_style('thickbox'); ?> <input id="upload_image" type="text" value="" /> <input id="upload_image_button" type="button" style="width:auto;height:20px;" value="上传图片" /> <script> jQuery(document).ready(function() { jQuery('#upload_image_button').click(function() { formfield = jQuery('#upload_image').attr('name'); // show Wordpress' uploader modal box tb_show('', '<?php echo admin_url(); ?>media-upload.php?type=image&TB_iframe=true'); return false; }); window.send_to_editor = function(html) { // this will execute automatically when a image uploaded and then clicked to 'insert to post' button imgurl = jQuery('img',html).attr('src'); // put uploaded image's url to #upload_image jQuery('#upload_image').val(imgurl); tb_remove(); } }); </script>
作者:黄聪
出处:http://www.cnblogs.com/huangcong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://www.cnblogs.com/huangcong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。