var uploadID = ''; /*setup the var*/ jQuery('.upload-button').click(function() { uploadID = jQuery(this).prev('input'); /*grab the specific input*/ formfield = jQuery('.upload').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'); uploadID.val(imgurl); /*assign the value to the input*/ tb_remove(); };
jQuery(document).ready(function() { var orig_send_to_editor = window.send_to_editor; jQuery('.upload_image_button').click(function() { formfield = jQuery(this).prev('input'); tb_show('Add Media', 'media-upload.php?type=file&TB_iframe=true'); window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); if(jQuery(imgurl).length == 0) { imgurl = jQuery(html).attr('href'); // We do this to get Links like PDF's } formfield.val(imgurl); tb_remove(); jQuery('#'+formfield.attr('name')).val(imgurl); window.send_to_editor = orig_send_to_editor; } return false; }); });
上传的字段就是这样的
You can also upload thumb from your PC using WordPress media manager(supported files are: .bmp, .BMP, .jpg, .JPG, .png, .PNG, jpeg, JPEG, .gif, .GIF).
You can also upload video to stream directly from your website, using WordPress media manager(supported files are: .mp4, .MP4, .flv, .FLV, .f4v, .F4V).
var uploadID = ''; // setup the var in a global scope var original_send_to_editor = window.send_to_editor; jQuery('.upload-button').click(function() { uploadID = jQuery(this).prev('input'); // set the uploadID variable to the value of the input before the upload button formfield = jQuery('.upload').attr('name'); tb_show('', 'media-upload.php?TB_iframe=true'); uploadBAR(); // Call if needed return false; }); function uploadBAR() { window.send_to_editor = function(html) { imgurl = jQuery(html).attr('href'); uploadID.val(imgurl); /*assign the value of the image src to the input*/ tb_remove(); window.send_to_editor = original_send_to_editor;//restore old send to editor function }; }