从厚盒图像上传器第二选项卡发送信息

时间:2011-03-08 作者:Asaf Chertkoff

在这个question 我已经找到了如何在图像上载程序中创建自定义选项卡。

代码如下:

add_filter(\'media_upload_tabs\', \'my_media_upload_tabs_filter\');

function my_media_upload_tabs_filter($tabs) {
        unset($tabs["type_url"]);
        unset($tabs[\'library\']);
        $newtab = array(\'ell_insert_gmap_tab\' => __(\'Google Map\',\'insertgmap\'));

        return array_merge($tabs,$newtab);
}

add_action(\'media_upload_ell_insert_gmap_tab\', \'media_upload_ell_gmap_tab\');

function media_upload_ell_gmap_tab() {
    return wp_iframe(\'media_upload_ell_gmap_form\', $errors );
}

function media_upload_ell_gmap_form() {
    ?>
    echo media_upload_header();
    ?>
    <h2>HTML Form</h2>

<?php
}  
现在,我想使用该选项卡的图像选择功能。因此,我将选项卡中的代码修改为:

  <form enctype="multipart/form-data" method="post" action="">
            <h3 class="media-title">Choose Background:</h3>
            Alternatively, you can choose one of these background images:<br/>
            <img style="float:left; margin:15px; cursor:pointer" id="background-Green-stripes" src="<?php bloginfo(\'url\'); ?>/wp-content/themes/mytheme/images/background-Green-stripes-thumb.jpg">
<a class="button choice_button" style="float:left; display:block" id="image 1">choose this</a>
            <img style="float:left; margin:15px; cursor:pointer" id="background-Pail-pink-squares.jpg" src="<?php bloginfo(\'url\'); ?>/wp-content/themes/mytheme/images/background-Pail-pink-squares-thumb.jpg">
<a class="button choice_button" style="float:left; display:block" id="image 2">choose this</a>
            <img style="float:left; margin:15px; cursor:pointer" id="background-Purple-wall.jpg" src="<?php bloginfo(\'url\'); ?>/wp-content/themes/mytheme/images/background-Purple-wall-thumb.jpg">
    <a class="button choice_button" style="float:left; display:block" id="image 3">choose this</a>
        </form> 
并试图从“window.send\\u to\\u editor”获取html,但不知道如何。。。有人能帮忙吗?我在这里迷路了。。。

1 个回复
最合适的回答,由SO网友:Asaf Chertkoff 整理而成

所以我决定,对我来说,我可以满足于更改顶部的输入字段。将其与本机选项一起使用的父级。我将其用于iframe选项卡的功能:

function media_upload_choosebackground_form() {
     media_upload_header();
    ?>
    <h3 class="media-title">HTML Form</h3>
        <img src="http://www.mimi.me/wp-content/themes/mimi.me_regular_sites/images/background-Green-stripes-thumb.jpg" style="cursor:pointer; float:left; margin:10px 0 0 10px" id="greenstripes" title="Green Stripes" />
        <img src="http://www.mimi.me/wp-content/themes/mimi.me_regular_sites/images/background-Pail-pink-squares-thumb.jpg" style="cursor:pointer; float:left; margin:10px 0 0 10px" id="Pailpinksquares" title="Pail pink squares" />
        <img src="http://www.mimi.me/wp-content/themes/mimi.me_regular_sites/images/background-Purple-wall-thumb.jpg" style="cursor:pointer; float:left; margin:10px 0 0 10px" id="Purplewall" title="Purple wall" />
<?php
}
这是每个图像的单击事件:

jQuery(\'#Purplewall\').click(function() {
        imgurl = "http://www.mimi.me/wp-content/themes/mimi.me_regular_sites/images/background-Purple-wall-thumb.jpg";
        $("#MoobBackgroundUpload", top.document).val(imgurl);
        $("#MoobBackgroundUploadButtonImg", top.document).attr(\'src\', imgurl);
        parent.tb_remove();
    });
我得到的是第二个带有图像选择器的选项卡,这是我首先想要的。对我有好处!

结束