Слайдер swipe
<!--КОД ДЛЯ СЛАЙДЕРА-->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/6.8.4/swiper-bundle.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/6.8.4/swiper-bundle.min.js"></script>


<div class="gallery">                
    <div class="swiper-container gallery-slider">
        <div class="swiper-wrapper">
        </div>
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>
    </div>

    <div class="swiper-container gallery-thumbs">
        <div class="swiper-wrapper">

        </div>
    </div>
</div>


<script>
document.addEventListener("DOMContentLoaded", function() {
    (function () {
        setTimeout(function() {
            const mainSliderClass = 'uc-main-slider';
            const touchSliderClass = 'uc-touch-slider';
            
            const mainSlider = document.querySelector('.'+mainSliderClass);
            const touchSlider = document.querySelector('.'+touchSliderClass);
        
            if(mainSlider!=null && touchSlider!=null){
                let totalSlides = 0;
                
                let totalRepeat = 0;
                let totalInterval = setInterval(function() {
                        totalSlides = +mainSlider.querySelector('.t-slds__items-wrapper').getAttribute('data-slider-totalslides');
                        if(totalSlides) {
                            createSlider();
                            clearInterval(totalInterval);
                        };
                        totalRepeat++;
                        if(totalRepeat>50) clearInterval(totalInterval);
                }, 100);   
                
                
                
                function createSlider(){
                
                    let topContent = '';
                    let bottomContent = '';
                    
                    for(let i=1; i<=totalSlides; i++){
                        let hasVideo = false;
                        const slideElem = mainSlider.querySelector('.t-slds__item[data-slide-index="'+i+'"]');
                        const slideImage = slideElem.querySelector('.t-slds__bgimg').getAttribute('data-original');
    
                        const videoSlide = slideElem.querySelector('.t-video-lazyload[data-videolazy-type]');
                        let serviceType = '';
                        if(videoSlide!=null) serviceType = videoSlide.getAttribute('data-videolazy-type');
                        
                        if(videoSlide!=null && serviceType=='rutube'){
                            hasVideo = true;
                            const videoID = videoSlide.getAttribute('data-videolazy-id');
                            topContent +=`
                                <div class="swiper-slide">
                                    <div class="swiper-slide-image media-box">
                                      <iframe
                                        class="rutube-player"
                                        width="100%" height="100%"
                                        src="https://rutube.ru/play/embed/${videoID}"
                                        frameborder="0"
                                        allow="clipboard-write; autoplay"
                                        allowfullscreen
                                      ></iframe>
                                    </div>
                                </div>
                            `;    
                        }else{
                            topContent +=`
                                <div class="swiper-slide">
                                    <div class="swiper-slide-image" style="background-image: url('${slideImage}')"></div>
                                </div>
                            `;    
                        };
                        
                        let videoClass = '';
                        if(hasVideo) videoClass = 'video-thumb';
                        
                        bottomContent +=`
                            <div class="swiper-slide ${videoClass}">
                                <div class="swiper-slide-image" style="background-image: url('${slideImage}')"></div>
                            </div>
                        `;
                    };
                    
                    touchSlider.querySelector('.gallery-slider .swiper-wrapper').innerHTML = topContent;
                    touchSlider.querySelector('.gallery-thumbs .swiper-wrapper').innerHTML = bottomContent;
                    
                    (function() {
                        
                        let minSlides = totalSlides>= 6;
                        console.log(minSlides);
          
                        const thumbs = new Swiper ('.'+touchSliderClass+' .gallery-thumbs', {
                            slidesPerView: 3,
                            spaceBetween: 10,
                            centeredSlides: false,
                            loop: minSlides,
                            slideToClickedSlide: true,
                            breakpoints: {
                                750: {
                                    slidesPerView: 3
                                },
                                750: {
                                    slidesPerView: 4
                                },
                                1000: {
                                    slidesPerView: 5
                                }
                            }
                        });
                        
                        
                        let thumbsMode = thumbs;
                        if(minSlides) thumbsMode = ``;
                        
                        const slider = new Swiper ('.'+touchSliderClass+' .gallery-slider', {
                            slidesPerView: 1,
                            centeredSlides: true,
                            loop: true,
                            navigation: {
                                nextEl:  '.'+touchSliderClass+' .swiper-button-next',
                                prevEl:  '.'+touchSliderClass+' .swiper-button-prev',
                            },
                            thumbs: { swiper: thumbsMode},
                            loopedSlides: 3, 
                            breakpoints: {
                                750: {
                                    loopedSlides: 3
                                },
                                750: {
                                    loopedSlides: 4
                                },
                                1000: {
                                    loopedSlides: 5
                                }
                            }
                        });
                        
                        
                        if(minSlides){
                            slider.controller.control = thumbs;
                            thumbs.controller.control = slider;
                        };
                        
                             slider.on('slideChange', function() {
                                document.querySelectorAll('.rutube-player').forEach(player => {
                                    try {
                                        player.contentWindow.postMessage(
                                            JSON.stringify({ type: 'player:pause', data: {} }), 
                                            '*'
                                        );
                                    } catch (e) {
                                        console.error('Ошибка при остановке видео:', e);
                                    }
                                });
                        
                                const currentSlide = slider.slides[slider.activeIndex];
                                const currentVideo = currentSlide.querySelector('.rutube-player');
                                
                                if (currentVideo) {
                                    try {
                                        currentVideo.contentWindow.postMessage(
                                            JSON.stringify({ type: 'player:play', data: {} }), 
                                            '*'
                                        );
                                    } catch (e) {
                                        console.error('Ошибка при запуске видео:', e);
                                    }
                                }
                            });
                      
                    })();
                    
                
                };
                
                
            };
        }, 500);
    })();    
});    
</script>


<style>

.uc-main-slider{
    display: none;
}

.media-box{
    inset:0; 
    width:100%; 
    height:100%;
    border:0; 
    object-fit:cover; 
    display:block;
}

.swiper-slide-image {
    aspect-ratio: 16/9;
    background: no-repeat 50%;
    background-size: cover;
    height: auto;
    position: relative;
}

.swiper-button-next, .swiper-button-prev {
    color: #000;
    width: 20px;
    height: 35px;
}

.swiper-button-next:after, .swiper-button-prev:after {
    font-size: 36px;
    font-weight: 600;
}

.gallery {
  width: 100%;
  margin: 40px auto;
}
.gallery-slider {
  width: 100%;
  height: auto;
  margin: 0 0 10px 0;
  cursor: grab;
}
.gallery-slider .swiper-slide {
  width: 100%;
  height: auto;
}
.gallery-slider .swiper-slide img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}
.gallery-thumbs {
  width: 100%;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}
.gallery-thumbs .swiper-slide {
  text-align: center;
  overflow: hidden;
  filter: brightness(0.4);
}
.gallery-thumbs .swiper-slide-active {
  filter: brightness(1);
}

.gallery-thumbs .swiper-slide-active {
  filter: brightness(1);
}


.gallery .swiper-wrapper .swiper-slide.swiper-slide-thumb-active {
    filter: brightness(1);
}

.swiper-wrapper:has(.swiper-slide-thumb-active) .swiper-slide-active {
    filter: brightness(0.4);
}


.gallery-thumbs .swiper-slide img {
  width: 100%;
  height: auto;
}

.video-thumb .swiper-slide-image {
    position: relative;
}

.video-thumb .swiper-slide-image:after {
    background-image: url(https://static.tildacdn.com/lib/icons/tilda/-/paint/ffffff--3-0-100/play_start.svg);
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 25%;
    background-repeat: no-repeat;
    background-position: center;
}

</style>
  1. Загружать картинку в блок GL01
  2. Если у картинки нужно видео, то нажимаем напротив кнопку видео, выбираем rutube и прописываем ссылку в "Ссылка на видео с Rutube или его ID" 7f86de0f13405346e7ae922943ecfa67
Book design is the art of incorporating the content, style, format, design, and sequence of the various components of a book into a coherent whole. In the words of Jan Tschichold, "Methods and rules that cannot be improved upon have been developed over centuries. To produce perfect books, these rules must be revived and applied." The front matter, or preliminaries, is the first section of a book and typically has the fewest pages. While all pages are counted, page numbers are generally not printed, whether the pages are blank or contain content.
Book design is the art of incorporating the content, style, format, design, and sequence of the various components of a book into a coherent whole. In the words of Jan Tschichold, "Methods and rules that cannot be improved upon have been developed over centuries. To produce perfect books, these rules must be revived and applied." The front matter, or preliminaries, is the first section of a book and typically has the fewest pages. While all pages are counted, page numbers are generally not printed, whether the pages are blank or contain content.
Book design is the art of incorporating the content, style, format, design, and sequence of the various components of a book into a coherent whole. In the words of Jan Tschichold, "Methods and rules that cannot be improved upon have been developed over centuries. To produce perfect books, these rules must be revived and applied." The front matter, or preliminaries, is the first section of a book and typically has the fewest pages. While all pages are counted, page numbers are generally not printed, whether the pages are blank or contain content.
Made on
Tilda