<?php
/**
 * Template part for displaying single post Gallery hero content
 */
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly

$position_to_content = rivax_get_option('single-format-gallery-position'); // inside / outside
$gallery_images = get_post_meta( get_the_ID(), 'rivax_single_gallery_images', true);
$gallery_images = (!empty($gallery_images) && is_string($gallery_images))? explode(',', $gallery_images) : '';

echo '<div class="single-hero-gallery">';

if($position_to_content == 'outside') {
	echo '<div class="rs-container">';
	echo '<div class="rs-row">';
	echo '<div class="rs-col-6">';
}
?>
    <div class="single-hero-gallery-container">
        <?php
        if(!empty($gallery_images)) {
            ?>
            <div class="swiper">
                <div class="swiper-wrapper">
                <?php
                foreach ($gallery_images as $id) {

                    $img_size = ($position_to_content == 'outside')? 'rivax-medium' : 'rivax-large';
                    $image_url = wp_get_attachment_image_url($id, $img_size);
                    if($image_url) {
                        echo '<div class="single-hero-gallery-item swiper-slide">';
                        echo '<img data-swiper-parallax-scale="1.2" data-swiper-parallax-x="10%" src="' . esc_url($image_url) . '" alt="' . get_the_title() . '">';
                        echo '</div>';
                    }
                }
                ?>
                </div>
                <div class="swiper-button-next"></div>
                <div class="swiper-button-prev"></div>
            </div>
			<?php rivax_single_hero_caption () ?>
            <?php
        }
        ?>
    </div>
<?php
if($position_to_content == 'inside') {
	get_template_part('template-parts/post/hero/title-section');
}

if($position_to_content == 'outside') {
	echo '</div>';
	echo '</div>';
	echo '</div>'; // .container
}

echo '</div>'; // .single-hero-gallery