I need a function that when a post is saved/updated, it will scan the post for the first image. This image has already been uploaded to the media gallery but it has not been attached to the post. So, after the function finds this image, it has to attach it to the post, and after it is attached, it has to set it as featured.
I have been looking for something like this over many forums, but unfortunately I haven’t been able to find it.
@toscho is right, please do some research before posting your question.
Here’s one peice of the puzzle that should get the ball rolling for you, courtesy of bavotasan.com. It finds the first image in the post and displays it.
Good luck.
P.S. Google search time < 30 seconds
great, yeah i did some research. I posted here as last resort. However, last night I found this plugin http://www.bbqiguana.com/wordpress-plugins/add-linked-images-to-gallery/
it does quite what I want, but it is getting only external images. How can I adapt it so it also gets internal images??
here is the code: