<?php
/**
 * The Template for displaying course featured image in single course bundle page
 *
 * This template can be overridden by copying it to yourtheme/masteriyo/single-course-bundle/featured-image.php.
 *
 * HOWEVER, on occasion Masteriyo will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @package Masteriyo\Templates
 * @version 2.12.0
 */

use Masteriyo\Enums\VideoSource;

defined( 'ABSPATH' ) || exit;
?>

<div class="masteriyo-bundle__featured-img masteriyo-feature-img">
	<?php if ( empty( $course_bundle->get_featured_image() ) && $course_bundle->has_featured_video() ) : ?>
			<?php if ( VideoSource::SELF_HOSTED === $featured_video_source || VideoSource::EXTERNAL === $featured_video_source ) {
					masteriyo_get_video_html( array(
							'width' => '100%',
							'src' => esc_attr( $course_bundle->get_featured_video_embed_url() ),
							'controls' => true,
					), true );
			} else {
					masteriyo_get_iframe_html( array(
							'width' => '100%',
							'style' => 'min-height: 230px;',
							'src' => esc_attr( $course_bundle->get_featured_video_embed_url() ),
							'allowFullScreen' => true,
					), true );
			} ?>
	<?php else : ?>
			<div class="masteriyo-feature-img" style="z-index: 10;">
					<?php echo wp_kses( $course_bundle->get_image( 'masteriyo_single' ), 'masteriyo_image' ); ?>
					<?php if ( $course_bundle->has_featured_video() ) : ?>
							<div class="masteriyo-play-featured-video-btn">
									<?php masteriyo_get_svg( 'play', true ); ?>
							</div>
					<?php endif; ?>
			</div>
	<?php endif; ?> 
</div>
<?php if ( $course_bundle->has_featured_video() ) : ?>
	<div class="masteriyo-overlay masteriyo-v-center masteriyo-featured-video-modal" style="display:none;">
		<div class="masteriyo--modal masteriyo-modal-featured-video masteriyo-transparent width-lg">
			<?php
			if ( $course_bundle->is_self_hosted_featured_video() || VideoSource::EXTERNAL === $course_bundle->get_featured_video_source() ) {
				masteriyo_get_video_html(
					array(
						'width'    => '100%',
						'style'    => 'height: calc(9 * 800px / 16);',
						'src'      => esc_attr( $course_bundle->get_featured_video_embed_url() ),
						'controls' => true,
					),
					true
				);
			} else {
				masteriyo_get_iframe_html(
					array(
						'width'           => '100%',
						'style'           => 'height: calc(9 * 800px / 16);',
						'src'             => esc_attr( $course_bundle->get_featured_video_embed_url() ),
						'allowFullScreen' => true,
					),
					true
				);
			}
			?>
		</div>
	</div>
<?php endif; ?>
<?php
