daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Feb 26th, 2010 1,347 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function() {
  2.  
  3.         var formfield;
  4.  
  5.         /* user clicks button on custom field, runs below code that opens new window */
  6.         jQuery('#upload_file_button').click(function() {
  7.                 formfield = jQuery('#upload_file').attr('name');
  8.                 tb_show('','media-upload.php?TB_iframe=true');
  9.  
  10.                 return false;
  11.  
  12.         });
  13.  
  14.         // user inserts file into post. only run custom if user started process using the above process
  15.         // window.send_to_editor(html) is how wp would normally handle the received data
  16.  
  17.         window.original_send_to_editor = window.send_to_editor;
  18.         window.send_to_editor = function(html){
  19.  
  20.                 if (formfield) {
  21.                         fileurl = jQuery(html).attr('href');
  22.        
  23.                         if(fileurl!=null) {
  24.                                 fileurl = jQuery(html).attr('src');
  25.                         }
  26.                         jQuery('#' + formfield).val(fileurl);
  27.  
  28.                         tb_remove();
  29.                 } else {
  30.                         window.original_send_to_editor(html);
  31.                 }
  32.         };
  33.  
  34. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top