ID, WP_OGP_POST_DESCRIPTION_KEY, true);
}
if (empty($description)) {
$description = get_the_excerpt();
}
return $description;
}
function ogp_post_image() {
$image = null;
if ($image_id = get_post_thumbnail_id()) {
$image = wp_get_attachment_image_src($image_id, WP_OGP_POST_IMAGE_SIZE);
}
if (empty($image)) {
// find first img element
global $post;
if (preg_match('/
]*src\s*=\s*("|\')([^"\']+)("|\')[^>]*>/i', $post->post_content, $matches)) {
return $matches[2];
}
}
return $image;
}
function ogp_post_section() {
$categories = get_the_category();
if (count($categories)>0) {
if ($categories[0]->name != __('Uncategorized')) {
return $categories[0]->name;
}
}
return false;
}
function ogp_post_tag() {
$tags = get_the_tags();
$tagnames = array();
if ($tags) {
foreach ($tags as $tag) {
$tagnames[] = $tag->name;
}
return implode(',', $tagnames);
}
return false;
}
?>