Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function() {
- var formfield;
- /* user clicks button on custom field, runs below code that opens new window */
- jQuery('#upload_file_button').click(function() {
- formfield = jQuery('#upload_file').attr('name');
- tb_show('','media-upload.php?TB_iframe=true');
- return false;
- });
- // user inserts file into post. only run custom if user started process using the above process
- // window.send_to_editor(html) is how wp would normally handle the received data
- window.original_send_to_editor = window.send_to_editor;
- window.send_to_editor = function(html){
- if (formfield) {
- fileurl = jQuery(html).attr('href');
- if(fileurl!=null) {
- fileurl = jQuery(html).attr('src');
- }
- jQuery('#' + formfield).val(fileurl);
- tb_remove();
- } else {
- window.original_send_to_editor(html);
- }
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement