• I am setting up an admin area and so far it is going okay. I have one text box working fine. It updates the database and all is well. I am trying to add an image upload using the wordpress media uploader. I have it displaying properly, it uploades the image fine, but when I press the save changes button, the input field empties. and nothing shows in the database. I have a feeling that I know what the issue is but I don’t know how to solve it. If I try to change it what I know it should be, the whole thing stops working. Here is my form

    <input id="upload_image" type="text" size="36" name="upload_image" value="" />
    <input id="upload_image_button" type="button" value="Upload Image" />

    I am using the new method of creating an admin area

    register_setting('about_options','about_options','validate_settings');
    	add_settings_section('about_page','About Page','section_cb','about_settings');
    	add_settings_field('logo','Add An Image','paradiso_image','about_settings','about_page');

    so right now, when I press the save changes button, I do see the option_name showing up in the database, but the key, value is empty in the option_value field. I can get as far as having the option key show up, but the value is empty. I am running this upload script

    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 = $('img',html).attr('src');
      $('#' + formfield).val(imgurl);
      tb_remove();
     } 
    
    });

    I did not write the script. Can you help?

The topic ‘help with admin code’ is closed to new replies.