Maybe my question is not clear enough.
Ok, let me reformulate.
I already show wide images on my blog, but they are too big to be taken care of by facebook. I am looking for a way to integrate images to Facebook links for each of my posts. Any idea?
My image is 650 px width… is it why Facebook does not take it? How can I do anything to go around this?
Facebook documentation
says that this in the header would work:
<link rel=”image_src” href=”http://www.onjd.com/design05/images/PH2/WableAFC205.jpg” />
But how to make that link change each time there is a new post and link to another smaller version of the bigger image?
bal, try using the WP built-in function to get the thumbnail version of the image. You can set the size of the thumbnail that WP will create when you upload the image on your post.
The code should look something like this:
//Get images attached to the post
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'order' => 'ASC',
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$img = wp_get_attachment_thumb_url( $attachment->ID );
echo '<link rel="image_src" href="'.$img.'">';
break;
}
Also check out this function, which could be used to pull the “medium” or “large” version of the uploaded image:
http://codex.ww.wp.xz.cn/Function_Reference/wp_get_attachment_image_src
The problem is that I don’t want the thumbnail to get displayed; I want regular visitors to see my 650 width pix… Smaller image is only for Facebook.
This is exactly what I was looking for! Thanks so much timnicholson!
baal666, did you not actually try what I posted? It doesn’t display a thumbnail in your post, it adds a <link rel=”image_src” href=”image-thumbnail”> line of code, which as you pointed out from the Facebook docs, tells Facebook what image(s) to show when you share/link to a post. This works on my site at http://xtremelysocial.com. Note that it only works when you use the wordpress image uploader. If you hard code a link to an image in the post it doesn’t work.
timnicholson, Where exactly would I paste that code? I just yesterday started having this problem and am not sure why! Thank you for your help!
Thanks for all, helpful information here.