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 it possible to use remote image as wordpress attachment? * Not stored on our server..

How about the code/script? i see that attachment is act as post in database.. seems it's possible.

UPDATE

what i need is to programatically attach image from remote URL and the final goal is the remote image can show as attachment page template just like uploaded image. is that possible?

Any suggestion would be highly appreciated.

Thanks.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You'll want to get very familiar with wp_insert_attachment(), download_url() and media_handle_sideload(). It's a bit lengthy to get into the details here, but it absolutely can be done. I used these methods to create a media tab that allows a user to put in a vimeo/youtube URL which I store in a postmeta and use their (vimeo/youtube) automatic thumbnail endpoints to attach an image to the post representing the video.

share|improve this answer
1  
Getting into details is what our site is about. Could you add an example? –  toscho Nov 10 '12 at 1:33
    
Hi, if using download_url() it will stored in our server.. the main purpose, what i am approach is using remote image(hotlink) as post attachment and will show in attachment page template with own permalink like wp image attachment. or maybe we can just insert remote image to postmeta? but i don't know if it's work as attachment permalink. Thanks –  Andy Nov 10 '12 at 2:47
    
You can control how the attachment permalink is defined with the attachment_link filter. core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/… –  totels Nov 11 '12 at 1:32
add comment

You can add images trough the 'from URL' tab in the 'add media' window. Or do you mean really attaching the images with the post? In that case I would try to fix something with custom meta fields where you can add the URL's. That way it's semi-attached.

share|improve this answer
    
Hi, thanks for the reply. what i need is to programatically attach image from remote URL and final goal is the remote image can show as attachment page template. is that possible? –  Andy Nov 10 '12 at 0:56
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.