Need help with media uploader (1 post)

  1. n-akesson
    Posted 3 years ago #

    I'm creating a theme options page and need some help with the upload function for logos.

    I've implemented a field and button, when the button is pressed it brings up the media upload iframe. But it wont add the url to the field.

    My field looks like this:

    <input id="n_options[logo_url]" name="n_options[logo_url]" type="text" value="<?php echo esc_attr($options['logo_url']); ?>" />

    And the .js like this:

    jQuery(document).ready(function() {
    jQuery('#upload_image_button').click(function() {
    	formfield = jQuery('#n_options[logo_url]').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');

    However, when I add a new field with the name 'hello' for example, and edit the .js to #hello instead of #n_options[logo_url] it works just fine, but I need it to add to the original field because that's how my options work. Any thoughts?

    I'm also wondering how to change the button in the media uploader to read 'Use Image' instead of 'Insert to Post'.

    Edit: I'm using the tutorial found on http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/ for the media uploader.

Topic Closed

This topic has been closed to new replies.

About this Topic