SupiryCraft
Minecraft 服务器
依星团队

状态
文章归档

状态
2021-03-14
function ravenclaw_share_post_image(){ global $post; if (has_post_thumbnail($post->ID)) /*有特色图就直接返回特色图*/ { $post_thumbnail_id = get_post_thumbnail_id( $post ); $img = wp_get_attachment_image_src( $post_thumbnail_id, 'full' ); $img = $img[0]; } else/*否则抓取第一张图片*/ { $content = $post->post_content; preg_match_all('//sim', $content, $strResult, PREG_PATTERN_ORDER); if (!empty($strResult[1])) { $img = $strResult[1][0]; }else{ $img = ravenclaw_option('tool_single_image'); } }; if (is_home())/*首页图片返回站点logo*/ { $img = ravenclaw_option('tool_share_image'); } return $img; }