3

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

7

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.

  • 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
0

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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