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.

Ideally what I'd like to do is hand a file to a function that returns the file as an attachment of the current post. Just as though it had been uploaded via the thickbox media uploader, but without the hassle of hijacking it's ugly interface.

Is there a plugin/library/function I can use with my own plugins to achieve this?

share|improve this question

1 Answer 1

You can do that programatically via wp_insert_attachment() function.

Here is an example at WP Codex: http://codex.wordpress.org/Function_Reference/wp_insert_attachment

share|improve this answer
    
Right, so does this trigger the rest of the stuff (moving the image to the uploads folder, resizing, generating thumbnails, etc)? I can't tell from the codex page. –  Tom Jul 4 '11 at 13:36

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.