投稿に画像がない場合エラーが発生するのを修正

This commit is contained in:
eai04191 2019-01-14 23:08:37 +09:00
parent 72ab8bf101
commit f134cbefa8
1 changed files with 7 additions and 4 deletions

View File

@ -24,11 +24,14 @@ class FantiaResolver implements Resolver
$node = $xpath->query("//meta[@property='twitter:image']")->item(0);
$ogpUrl = $node->getAttribute('content');
preg_match("~https:\/\/fantia\.s3\.amazonaws\.com\/uploads\/post\/file\/{$postId}\/ogp_(.*?).jpg~", $ogpUrl, $match);
$uuid = $match[1];
// 投稿に画像がない場合ogp.jpgでない場合のみ大きい画像に変換する
if($ogpUrl != "http://fantia.jp/images/ogp.jpg"){
preg_match("~https:\/\/fantia\.s3\.amazonaws\.com\/uploads\/post\/file\/{$postId}\/ogp_(.*?).jpg~", $ogpUrl, $match);
$uuid = $match[1];
// 大きい画像に変換
$metadata->image = "https://c.fantia.jp/uploads/post/file/{$postId}/main_{$uuid}.jpg";
// 大きい画像に変換
$metadata->image = "https://c.fantia.jp/uploads/post/file/{$postId}/main_{$uuid}.jpg";
}
return $metadata;
} else {