<?php 
    // Get gallery image IDs.
    $gallery_image_ids = '';
    $gallery_image_ids = get_post_meta(get_the_ID(), 'gallery_image_ids', true);

    if ( has_post_format('gallery') && !empty( $gallery_image_ids )) {
        $gallery_images = explode(',', $gallery_image_ids);
        ?>
            <div class="post-thumbnail-wrapper post-gallery-slider">
                <div class="swiper gallery-slider">
                    <div class="swiper-wrapper">
                        <?php foreach ( $gallery_images as $gallery_image ) : 
                        $image_url = wp_get_attachment_image_src( $gallery_image, 'newscope-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"><i class="fas fa-angle-double-right"></i></div>
                    <div class="swiper-button-prev"><i class="fas fa-angle-double-left"></i></div>
                </div>
            </div>
        <?php 
    }else{
        if( has_post_thumbnail() ){
            ?>
                <div class="post-thumbnail-wrapper">
                    <img src="<?php echo get_the_post_thumbnail_url( get_the_ID(), 'newscope-large' ) ?>"
                        alt="<?php echo get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ); ?>">
                </div>
            <?php 
        }
    }
?>