Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How to move an image in a plugin to the upload directory and make it as a media of wordpress?

I would like to use them in posts.

Expand question:

I would like to generate images using other programs and saved in the temporary folder of my plugin directory.

eg. plugin-name/tmp/image_01.jpg

Then, I would like to upload the image to the upload directory an use it as a media source.

Is that possible?

share|improve this question
    
Can you expand on why you need to do this? –  mrwweb Apr 27 '12 at 18:17
    
@mrwweb Sure, is that clear? I hope that's helpful. :) –  goodseller Apr 27 '12 at 18:30
add comment

1 Answer

Check out wp_insert_attachment(). Takes an $attachment array of metadata and a $filename and inserts it into the media library. The Codex page has a good snippet so I won't include one here.

share|improve this answer
    
@goodseller if this answered your problem, make sure to accept it as the answer. Otherwise, update your question and explain why this didn't work. –  mrwweb May 8 '12 at 19:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.