mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Create Open Graph meta tags for book/page/chapter/shelf
This commit is contained in:
@ -126,4 +126,18 @@ class Page extends BookChild
|
||||
$refreshed->html = (new PageContent($refreshed))->render();
|
||||
return $refreshed;
|
||||
}
|
||||
|
||||
public function getCoverImage(): string
|
||||
{
|
||||
$dom = new \DomDocument();
|
||||
$dom->loadHTML($this->html);
|
||||
$images = $dom->getElementsByTagName('img');
|
||||
|
||||
try {
|
||||
$cover = $images->length > 0 ? $images[0]->getAttribute('src') : $this->book->getBookCover();
|
||||
} catch (Exception $err) {
|
||||
$cover = $this->book->getBookCover();
|
||||
}
|
||||
return $cover;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user