<?php
if (get_post_meta($post->ID, 'Glamer_postmeta_video', true)) {
    $video_meta = get_post_meta($post->ID, 'Glamer_postmeta_video', true);
} else {
    $video_meta = array();
}

if (array_key_exists('Glamer_post_video', $video_meta) && ! empty($video_meta['Glamer_post_video'])) {
    $video_url = $video_meta['Glamer_post_video'];
} else {
    $video_url = '';
}
?>

<?php if (has_post_thumbnail()) : ?>
    <div class="post-thumbnail-wrapper">
        <img src="<?php echo get_the_post_thumbnail_url(get_the_ID(), 'glamer-large') ?>"
            alt="<?php echo get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true); ?>">
        <?php if ($video_url): ?>
            <div class="post-video-button-wrapper">
                <a href="<?php echo esc_url($video_url); ?>" class="post-video video-button">
                    <i class="fas fa-play"></i>
                </a>
            </div>
        <?php endif; ?>
    </div>
<?php else : ?>
    <div class="post-thumbnail-video-wrapper">
        <?php echo wp_oembed_get($video_url); ?>
    </div>
<?php endif; ?>