• 板邓:wordpress自定义页面上传图片功能


    <?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="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&amp;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://8dseo.com
  • 相关阅读:
    算法第二章上机实践报告
    算法第一章作业
    第7章学习小结 不使用STL-map过实践题:QQ帐户的申请与登陆
    第6章学习小结
    HDU
    HDU 2089 不要62(数位DP)
    char-2
    chart-7
    chart-6
    char-8
  • 原文地址:https://www.cnblogs.com/xbdeng/p/5617671.html
Copyright © 2020-2023  润新知