我有一个自定义元文件上传文件功能,但问题是,我无法获得文件按钮值时,点击“插入到邮政”,以下是我的jQuery代码
window.send_to_editor = function(html)
{
dlink = jQuery('button.urlfile',html).attr('title');
jQuery('#download_link').val(dlink);
tb_remove();
}
tb_show('', 'media-upload.php?post_id=1&type=image&TB_iframe=true');
return false;发布于 2012-03-23 21:09:28
试试这个:
window.send_to_editor = function(html){
dlink = jQuery('img',html).attr('src');
jQuery('#download_link').val(dlink);
tb_remove();
}发布于 2012-12-20 13:36:44
<div>
<label style="float:left; margin: 5px 5px 0 0;">Image 4:</label>
<input type="text" id="image_4" name="image_4" value="" style="width: 550px; float:left; margin:0 5px;"/>
<input id="_btn" class="upload_image_button" type="button" value="Upload Image" />
<input type="hidden" name="image4_id" id="image4_id" value="<?php echo $image_id4; ?>" />
</div>
<script>
jQuery(document).ready(function () {
var formfield;
var id;
jQuery('.upload_image_button').click(function () {
jQuery('html').addClass('Image');
formfield = jQuery(this).prev().attr('name');
id = jQuery(this).next().attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.original_send_to_editor = window.send_to_editor;
window.send_to_editor = function (html) {
if (formfield) {
fileurl = jQuery('img', html).attr('src');
jQuery('#' + formfield).val(fileurl);
imgclass = jQuery('img', html).attr('class');
imgid = parseInt(imgclass.replace(/\D/g, ''), 10);
jQuery('#' + id).val(imgid);
tb_remove();
jQuery('html').removeClass('Image');
} else {
window.original_send_to_editor(html);
}
};
});
</script>https://wordpress.stackexchange.com/questions/46589
复制相似问题