<?php
/* @var \Tangibledesign\MyHome\Widgets\User\UserImageWidget $mhCurrentWidget */
global $mhCurrentWidget, $mhUser;

$mhUser = $mhCurrentWidget->getUser();
if (!$mhUser) {
    return;
}

$mhImageUrl = $mhUser->getImageUrl($mhCurrentWidget->getImageSize());
if (!$mhImageUrl) {
    return;
}

if ($mhCurrentWidget->linkUser()) : ?>
    <a
            class="myhome-user-image-widget"
            href="<?php echo esc_url($mhUser->getUrl()); ?>"
    >
        <img
                src="<?php echo esc_url($mhImageUrl); ?>"
                alt="<?php echo esc_attr($mhUser->getDisplayName()); ?>"
        >
    </a>
<?php else : ?>
    <div class="myhome-user-image-widget">
        <img
                src="<?php echo esc_url($mhImageUrl); ?>"
                alt="<?php echo esc_attr($mhUser->getDisplayName()); ?>"
        >
    </div>
<?php
endif;