get_results("SELECT guid, post_content, post_mime_type, post_title FROM $wpdb->posts WHERE post_parent = $id ORDER BY ID ASC");*/ $image_data = $wpdb->get_results("SELECT guid, post_content, post_mime_type, post_title FROM wp_posts WHERE id = $id"); $match_count = preg_match_all("//", $image_data[0]->post_content, $match_array, PREG_PATTERN_ORDER); if($match_count == 0){ $match_count = preg_match_all("//", $image_data[1]->post_content, $match_array, PREG_PATTERN_ORDER); if($match_count == 0){ $match_count = preg_match_all("/]+>/i", $image_data[1]->post_content, $match_array, PREG_PATTERN_ORDER); if($match_count == 0) $match_count = preg_match_all("//", $image_data[0]->post_content, $match_array, PREG_PATTERN_ORDER); if($match_count == 0){ $match_count = preg_match_all("/youtube.com\/watch\?v=(\S*)/", $image_data[1]->post_content, $match_array, PREG_PATTERN_ORDER); if($match_count == 0) $match_count = preg_match_all("/youtube.com\/watch\?v=(\S*)/", $image_data[0]->post_content, $match_array, PREG_PATTERN_ORDER); if($match_count != 0) $img = 'http://img.youtube.com/vi/' . $match_array[1][0] . '/0.jpg'; } } } if( $img == '') $img = $match_array[1][0]; $wp_query = $temp; return $img; } ?>