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:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user