0
當我從wordpress分享博客文章時,WP默認爲帖子的精選圖片,並且不提供任何選項來從帖子內選擇其他圖片。我需要停止fb看到特色圖片,因爲它與共享無關,並允許它爲其他圖片刮頁。停止facebook使用精選圖像進行博客分享
我的博客文章頭中的代碼如下:
<meta property="og:image" content="<?php echo get_fbimage(); ?>"/>
而且功能:
function get_fbimage() {
$src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '', '');
if (has_post_thumbnail($post->ID)) {
$fbimage = $src[0];
} else {
global $post, $posts;
$fbimage = '';
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',
$post->post_content, $matches);
$fbimage = $matches [1] [0];
}
if(empty($fbimage)) {
$fbimage = "";
}
return $fbimage;
}
任何意見大大收到
我不知道這是否會直接回答你的問題,但在https://developers.facebook.com/tools/debug/上有一個Facebook調試工具,它讀取一個URL,告訴你它正在拾取什麼,提供(一些)關於爲什麼它達成結論的信息。 我發現我需要改變自己的圖像尺寸才能將我想要的圖像記錄爲共享圖像。 防止Facebook看到Open Graph規定的圖像可能不可能,因爲它嚴重註冊到OG格式。 – Scoop 2014-10-03 10:59:31