Fix error when blog post has no featured image

This commit is contained in:
grandeljay 2022-11-08 12:58:20 +01:00
parent 36ba266587
commit d3a6cf34bc
2 changed files with 3 additions and 3 deletions

View file

@ -41,7 +41,7 @@ if ('en' !== \Locale::getPrimaryLanguage($_SESSION['user']->getLocale())) {
\IntlDateFormatter::MEDIUM, \IntlDateFormatter::MEDIUM,
\IntlDateFormatter::NONE \IntlDateFormatter::NONE
); );
$mediaHTML = isset($post->featured_media) ? Blog::getMediaHTML($post->featured_media) : ''; $mediaHTML = isset($post->featured_media) && 0 !== $post->featured_media ? Blog::getMediaHTML($post->featured_media) : '';
$categoriesHTML = Blog::getCategoriesHTML($post->categories); $categoriesHTML = Blog::getCategoriesHTML($post->categories);
$postLink = Page::PAGE_POST . '&slug=' . $post->slug; $postLink = Page::PAGE_POST . '&slug=' . $post->slug;
?> ?>

View file

@ -11,8 +11,8 @@ namespace wishthis;
$postSlug = $_GET['slug']; $postSlug = $_GET['slug'];
$posts = Blog::getPreviousCurrentNextPostBySlug($postSlug); $posts = Blog::getPreviousCurrentNextPostBySlug($postSlug);
$post = $posts['current']; $post = $posts['current'];
$postMediaHTML = isset($post->featured_media) ? Blog::getMediaHTML($post->featured_media) : ''; $postMediaHTML = isset($post->featured_media) && 0 !== $post->featured_media ? Blog::getMediaHTML($post->featured_media) : '';
$postMedia = isset($post->featured_media) ? Blog::getMedia($post->featured_media) : new \stdClss(); $postMedia = isset($post->featured_media) && 0 !== $post->featured_media ? Blog::getMedia($post->featured_media) : new \stdClass();
$page = new Page(__FILE__, $post->title->rendered); $page = new Page(__FILE__, $post->title->rendered);