zoukankan      html  css  js  c++  java
  • 黄聪:如何在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>

  • 相关阅读:
    vsprintf解析
    带grub的软盘镜像制作
    SunnyOS准备4
    SunnyOS准备3
    SunnyOS准备1
    汇编第七日
    汇编第六日
    解决k8s集群中mount volume失败的问题
    更新k8s集群的证书
    为k8s集群配置自定义告警
  • 原文地址:https://www.cnblogs.com/huangcong/p/2629984.html
Copyright © 2011-2022 走看看