mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 04:05:57 +00:00
Code cleanup, bug squashing
This commit is contained in:
parent
7ef17bb394
commit
a0bfdf0e5c
@ -130,9 +130,10 @@ class Page extends BookChild
|
|||||||
/**
|
/**
|
||||||
* Returns URL to a cover image for the page.
|
* Returns URL to a cover image for the page.
|
||||||
*/
|
*/
|
||||||
public function getCoverImage(): string
|
public function getCoverImage()
|
||||||
{
|
{
|
||||||
$default = $this->book->getBookCover();
|
//$default = $this->book->getBookCover();
|
||||||
|
$default = url('/logo.png');
|
||||||
|
|
||||||
$firstImage = (new PageContent($this))->fetchFirstImage();
|
$firstImage = (new PageContent($this))->fetchFirstImage();
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ class PageContent
|
|||||||
/**
|
/**
|
||||||
* Retrieve first image in page content and return the source URL.
|
* Retrieve first image in page content and return the source URL.
|
||||||
*/
|
*/
|
||||||
public function fetchFirstImage(): string
|
public function fetchFirstImage()
|
||||||
{
|
{
|
||||||
$htmlContent = $this->page->html;
|
$htmlContent = $this->page->html;
|
||||||
|
|
||||||
@ -370,6 +370,6 @@ class PageContent
|
|||||||
$dom->loadHTML($htmlContent);
|
$dom->loadHTML($htmlContent);
|
||||||
$images = $dom->getElementsByTagName('img');
|
$images = $dom->getElementsByTagName('img');
|
||||||
|
|
||||||
return $images ? $images[0]->getAttribute('src') : null;
|
return $images->length > 0 ? $images[0]->getAttribute('src') : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
@push('social-meta')
|
@push('social-meta')
|
||||||
<meta property="og:description" content="{{ Str::limit($page->text, 100, '...') }}">
|
<meta property="og:description" content="{{ Str::limit($page->text, 100, '...') }}">
|
||||||
<meta property="og:image" content="{{ $page->getCoverImage() }}">
|
<meta property="og:image" content="{{ $page->getCoverImage() }}">
|
||||||
|
|
||||||
|
|
||||||
$pageContent->getNavigation($page->html);
|
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
@section('body')
|
@section('body')
|
||||||
|
Loading…
Reference in New Issue
Block a user