1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Code cleanup, refactor

Updated to use Str::length for entity descriptions.
Moved function to get first image in page to PageContent class.
This commit is contained in:
James Geiger
2021-02-09 00:16:24 -06:00
parent e458411f91
commit 48587d2c38
7 changed files with 31 additions and 11 deletions

View File

@@ -358,4 +358,18 @@ class PageContent
return $html;
}
/**
* Retrieve first image in page content and return the source URL.
*/
public function fetchFirstImage(): string
{
$htmlContent = $this->page->html;
$dom = new \DomDocument();
$dom->loadHTML($htmlContent);
$images = $dom->getElementsByTagName('img');
return $images[0]->getAttribute('src');
}
}