meta image for blog post covers

This commit is contained in:
Jeremy Kauffman 2016-07-15 13:32:10 -04:00
parent 8f8948c6ce
commit cbccfa6e74
2 changed files with 17 additions and 3 deletions

View file

@ -244,9 +244,23 @@ class Post
public function getImageUrls() public function getImageUrls()
{ {
$urls = [];
$cover = $this->getCover();
if ($cover)
{
$urls[] = 'https://' . $_SERVER['SERVER_NAME'] . '/img/' . $cover;
}
$matches = []; $matches = [];
preg_match_all('/!\[.*?\]\((.*?)\)/', $this->markdown, $matches); preg_match_all('/!\[.*?\]\((.*?)\)/', $this->markdown, $matches);
return $matches ? $matches[1] : [];
if ($matches)
{
$urls = array_merge($urls, $matches[1]);
}
return $urls;
} }
protected function markdownToText($markdown) protected function markdownToText($markdown)