diff --git a/app/MetadataResolver/ToranoanaResolver.php b/app/MetadataResolver/ToranoanaResolver.php index 34559fe..581f106 100644 --- a/app/MetadataResolver/ToranoanaResolver.php +++ b/app/MetadataResolver/ToranoanaResolver.php @@ -28,7 +28,17 @@ class ToranoanaResolver implements Resolver $res = $this->client->get($url, ['cookies' => $cookieJar]); if ($res->getStatusCode() === 200) { - return $this->ogpResolver->parse($res->getBody()); + $metadata = $this->ogpResolver->parse($res->getBody()); + + $dom = new \DOMDocument(); + @$dom->loadHTML(mb_convert_encoding($res->getBody(), 'HTML-ENTITIES', 'UTF-8')); + $xpath = new \DOMXPath($dom); + $imgNode = $xpath->query('//*[@id="preview"]//img')->item(0); + if ($imgNode !== null) { + $metadata->image = $imgNode->getAttribute('src'); + } + + return $metadata; } else { throw new \RuntimeException("{$res->getStatusCode()}: $url"); }