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.

Is there a way for me to add an <img> tag in a Post, but then have a plugin download that image, and put it on the server for me instead of me needing to manually download the file from online to my computer and then upload it to the server?

Thanks

share|improve this question
    
You can also run it afterwards instead of on-demand: wordpress.stackexchange.com/questions/3442/… –  edelwater Nov 28 '10 at 15:58

3 Answers 3

up vote 7 down vote accepted

Sure. You could hook the save_post action, use WP_Http class to download it and then insert it as an attachment using wp_insert_attachment and wp_update_attachment_metadata().

It's not trivial but shouldn't be that hard.

share|improve this answer
    
I've built similar systems before ... you can go further and make the plug-in automatically re-size the image for your purposes, too. There's no reason to store a 1024x600 image on the server if you're only displaying it as 256x150. –  EAMann Aug 24 '10 at 1:36
    
Yeah, I wish I (or someone else) had time to code up a plugin for this. Maybe after I get some client work done... :) –  MikeSchinkel Aug 24 '10 at 3:01

There is a plugin called "Add Linked Images To Gallery" - when you insert an image to your post from an external website, this plugin automatically save a local copy and replace the link to the external site with the local address. hope it helps.

share|improve this answer

There is a newer plugin in the Wordpress repository which works. Add Linked images to Gallery does not work anymore. Import External Images

share|improve this answer

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.