我正在尝试将多个图像上载到媒体库,然后我可以获取图像的URL并将其插入网站上的自定义页面,但由于某些原因,当我单击其他输入按钮时,它不起作用,也不会显示媒体库上载下拉列表并选择第一个输入文本字段。我不明白为什么我不能使用其他输入同时上传多个图像。
有人能看出我做错了什么吗?
这是JS:
<script language="JavaScript">
jQuery(document).ready(function() {
jQuery(\'#upload_image_button\').click(function() {
formfield = jQuery(\'#upload_image\').attr(\'name\');
tb_show(\'\', \'media-upload.php?type=image&TB_iframe=true\');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery(\'img\',html).attr(\'src\');
jQuery(\'#upload_image\').val(imgurl);
tb_remove();
}
});
</script>
这是输入字段表单:
<tr valign="top">
<td>Upload Ad for Position 1</td>
<td><label for="upload_image">
<input id="upload_image" type="text" size="36" name="upload_ad1_doc" value="<?php echo $gearimage; ?>" />
<input id="upload_image_button" type="button" value="Upload Image" />
<br />Enter an URL or upload an image for the ad.
</label>
</td>
</tr><br /><br />
<tr valign="top">
<td>Upload Ad for Position 2</td>
<td><label for="upload_image">
<input id="upload_image" type="text" size="36" name="upload_ad2_doc" value="<?php echo $gearimage; ?>" />
<input id="upload_image_button" type="button" value="Upload Image" />
<br />Enter an URL or upload an image for the ad.
</label>
</td>
</tr><br /><br />
<tr valign="top">
<td>Upload Ad for Position 3</td>
<td><label for="upload_image">
<input id="upload_image" type="text" size="36" name="upload_ad3_doc" value="<?php echo $gearimage; ?>" />
<input id="upload_image_button" type="button" value="Upload Image" />
<br />Enter an URL or upload an image for the ad.
</label>
</td>
</tr>
function wp_gear_manager_admin_scripts() {
wp_enqueue_script(\'media-upload\');
wp_enqueue_script(\'thickbox\');
wp_enqueue_script(\'jquery\');
}
function wp_gear_manager_admin_styles() {
wp_enqueue_style(\'thickbox\');
}
add_action(\'admin_print_scripts\', \'wp_gear_manager_admin_scripts\');
add_action(\'admin_print_styles\', \'wp_gear_manager_admin_styles\');