<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$service_id = $args['p_id'] ?? get_the_ID();

$service_thumbnail_id = get_post_thumbnail_id( $service_id );
$service_description  = gigneo_post_meta( $service_id, '_gigneo_pm_description' );
$service_gallery      = gigneo_post_meta( $service_id, '_gigneo_pm_gallery' );
$service_video_type   = gigneo_post_meta( $service_id, '_gigneo_pm_video_type' );

//Video
$service_video_link = '';
if ( 'link' === $service_video_type ) {
	$service_video_link = gigneo_post_meta( $service_id, '_gigneo_pm_video_link' );
} else {
	$service_video      = gigneo_post_meta( $service_id, '_gigneo_pm_video' );
	$service_video_link = wp_get_attachment_url( $service_video ) ?? '';
}


?>
<div class="gn-slick-slider gn-slick-theme gn-service-media-slider">
	<div class="gn-slick-slide">
		<figure class="gn-service-media">
			<?php gigneo_attachment_image_src( $service_thumbnail_id, 'large' ); ?>
			<?php if ( ! empty( $service_video_link ) ) { ?>
				<a href="<?php echo esc_url( $service_video_link ); ?>" data-gn-fancybox
					class="gn-play-video-toggle">
					<i class="hi hi-play" aria-hidden="true"></i>
				</a>
			<?php } ?>
		</figure>
	</div>
	<?php
	if ( ! empty( $service_gallery ) && is_array( $service_gallery ) ) {
		foreach ( $service_gallery as $gallery_item ) {
			if ( intval( $gallery_item ) === intval( $service_thumbnail_id ) ) {
				continue;
			}
			?>
			<div class="gn-slick-slide">
				<figure class="gn-service-media"><?php gigneo_attachment_image_src( $gallery_item, 'large' ); ?>
				</figure>
			</div>
			<?php
		}
	}
	?>
</div>