tags:

views:

304

answers:

3

hello

I am developing a wordpress plugin and I need to have a field where I can upload an image. Since wordpress has a very handly uploader it would be great if I could use that.

anyone know if that's possible?

Thanks

+1  A: 

If you only want to upload a file, you don't need the media uploader. A simple form is all you need.

To call the media uploader you need a link like this:

<a onclick="return false;" title="Upload image" class="thickbox" id="add_image" href="media-upload.php?type=image&amp;TB_iframe=true&amp;width=640&amp;height=105">Upload Image</a>

You'll maybe have to append your URL to media-upload.php to make it working.

Kau-Boy
>>> You'll maybe have to append your URL to media-upload.php to make it working.how do I do that?
vick
Kau-Boy
What is your plugin going to do? I have written 3 plugins myself. Maybe your plugin might be useful for me. And did you know that you can vote up a answer AND accept it ;)
Kau-Boy
A: 

The link works great!

Thanks for that suggestion Kau-Boy.

When in the media uploader and you click "Insert into Post", it only sends the information about the selected image to the form field with id "content".

Do you know of a way to have it send the url of the selected image to a different textfield?

For example:

if I had this: <a onclick="return false;" title="Upload image" class="thickbox" id="add_image" href="media-upload.php?type=image&amp;TB_iframe=true&amp;width=640&amp;height=105">Upload Image</a> and then had: <input type="text" id="imagevalue" />

How could I get the media-upload "Insert into post" button to pass the selected image url to the input box with id "imagevalue"

?

Senica Gonzalez
Found answer here: http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/
Senica Gonzalez