<?php
if ( get_post_meta( get_the_ID(), 'glamer_postmeta_gallery', true ) ) {
	$gallery_meta = get_post_meta( get_the_ID(), 'glamer_postmeta_gallery', true );
} else {
	$gallery_meta = array();
}
if ( array_key_exists( 'glamer_post_gallery', $gallery_meta ) ) {
	$gallery_images = explode( ',', $gallery_meta['glamer_post_gallery'] );
} else {
	$gallery_images = '';
}

?>

<?php if ( is_array($gallery_images) && $gallery_images[0] !== '' ) : ?>


    <div class="post-thumbnail-wrapper">
        <div class="swiper post-gallery-slider">
            <div class="swiper-wrapper">
                <?php foreach ( $gallery_images as $gallery_image ) : 
                $image_url = wp_get_attachment_image_src( $gallery_image, 'glamer-large');
                if( !empty($image_url) ) :
                ?>
                    <div class="post-gallery-item swiper-slide">
                        <img src="<?php echo esc_url( $image_url[0] ); ?>" alt="<?php echo get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ); ?>">
                    </div>
                <?php endif; endforeach; ?>
            </div>
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
        </div>
    </div>
<?php else : ?>
	<?php if ( has_post_thumbnail() ) : ?>
        <div class="post-thumbnail-wrapper">
            <?php the_post_thumbnail('glamer-large'); ?>
        </div>
	<?php endif; ?>
<?php endif; ?>