<?php

/* @var Tangibledesign\MyHome\Widgets\BlogPost\BlogPostContentWidget $mhCurrentWidget */
global $mhCurrentWidget;

$mhBlogPost = $mhCurrentWidget->getBlogPost();
if (!$mhBlogPost) {
    return;
}

$mhShowFeaturedImage = $mhCurrentWidget->showFeaturedImage();
$mhImageUrl = $mhShowFeaturedImage ? $mhBlogPost->getImageUrl() : false;
?>
<div class="myhome-blog-content-widget">
    <?php if (!empty($mhImageUrl)) : ?>
        <div class="myhome-blog-content-widget__image">
            <img
                src="<?php echo esc_url($mhImageUrl); ?>"
                alt="<?php echo esc_attr($mhBlogPost->getName()); ?>"
                loading="lazy"
            />
        </div>
    <?php endif; ?>

    <div class="myhome-blog-content-widget__content">
        <?php $mhBlogPost->displayContent(); ?>
    </div>
</div>