/**** ADD FB IMAGES***/ //Adding the Open Graph in the Language Attributes function add_opengraph_doctype( $output ) { return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"'; } add_filter('language_attributes', 'add_opengraph_doctype'); //Lets add Open Graph Meta Info function insert_fb_in_head() { global $post; if ( !is_singular()) //if it is not a post or a page return; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo "\n"; } add_action( 'wp_head', 'insert_fb_in_head', 5 ); //grab first image url from post content // base function from http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it function catch_that_image($inLoop = true) { global $post, $posts; $first_img = ''; if ($inLoop) { ob_start(); ob_end_clean(); } $output = preg_match_all('//i', $post->post_content, $matches); $first_img = $matches[1][0]; if(empty($first_img)){ //Defines a default image $first_img = home_url("/wp-content/uploads/newavatar.png"); } return $first_img; }