diff --git a/model/Post.class.php b/model/Post.class.php index f5d38659..9f413158 100644 --- a/model/Post.class.php +++ b/model/Post.class.php @@ -236,6 +236,13 @@ class Post return $this->getPostNum() % $maxStyles + 1; } + public function getImageUrls() + { + $matches = []; + preg_match_all('/!\[.*?\]\((.*?)\)/', $this->markdown, $matches); + return $matches ? $matches[1] : []; + } + protected function markdownToText($markdown) { $replacements = [ diff --git a/view/Response.class.php b/view/Response.class.php index 4eaf814f..b959b36e 100644 --- a/view/Response.class.php +++ b/view/Response.class.php @@ -17,16 +17,24 @@ class Response 'css' => [] ], // $bodyCssClasses = [], - $metaImg = ''; + $metaImages = []; public static function setMetaDescription($description) { static::$metaDescription = $description; } - public static function setMetaImage($url) + public static function addMetaImage($url) { - static::$metaImg = $url; + static::$metaImages[] = $url; + } + + public static function addMetaImages(array $urls) + { + foreach($urls as $url) + { + static::addMetaImage($url); + } } public static function getMetaDescription() @@ -34,9 +42,9 @@ class Response return static::$metaDescription ?: 'A Content Revolution'; } - public static function getMetaImage() + public static function getMetaImages() { - return static::$metaImg ?: 'http://lbry.io/img/lbry-dark-1600x528.png'; + return static::$metaImages ?: ['https://lbry.io/img/lbry-dark-1600x528.png']; } public static function setMetaTitle($title) diff --git a/view/View.class.php b/view/View.class.php index a924e753..20d3e074 100644 --- a/view/View.class.php +++ b/view/View.class.php @@ -14,9 +14,6 @@ class View { const LAYOUT_PARAMS = '_layout_params'; - protected static $metaDescription = '', - $metaImg = ''; - public static function render($template, array $vars = []) { if (static::isMarkdown($template)) @@ -92,26 +89,6 @@ class View return '/img/' . $image; } - public static function setMetaDescription($description) - { - static::$metaDescription = $description; - } - - public static function setMetaImage($url) - { - static::$metaImg = $url; - } - - public static function getMetaDescription() - { - return static::$metaDescription ?: 'A Content Revolution'; - } - - public static function getMetaImage() - { - return static::$metaImg ?: 'https://lbry.io/img/lbry-dark-1600x528.png'; - } - public static function parseMarkdown($template) { $path = static::getFullPath($template); diff --git a/view/template/content/post.php b/view/template/content/post.php index e75f3eec..b31746c3 100644 --- a/view/template/content/post.php +++ b/view/template/content/post.php @@ -1,4 +1,5 @@ getTitle()) ?> +getImageUrls()) ?>
diff --git a/view/template/layout/basic.php b/view/template/layout/basic.php index 0ca21c71..eee0a23a 100644 --- a/view/template/layout/basic.php +++ b/view/template/layout/basic.php @@ -42,9 +42,12 @@ - + + + + diff --git a/view/template/page/team.php b/view/template/page/team.php index fc81dba2..c4d08d09 100644 --- a/view/template/page/team.php +++ b/view/template/page/team.php @@ -1,5 +1,5 @@ - + false]) ?>
diff --git a/view/template/page/why.php b/view/template/page/why.php index 82ab2c5a..50be6f4c 100644 --- a/view/template/page/why.php +++ b/view/template/page/why.php @@ -1,5 +1,5 @@ - + false]) ?>