I
I
Ivan13312021-03-02 16:07:41
YouTube
Ivan1331, 2021-03-02 16:07:41

How to make carousel from youtube video?

You need to make a carousel from YouTube videos. Through ACF, I created a repeater and put the oEmbed field in it and in the admin panel I put links to the video I need. This is how I output:

<div class="owl-carousel owl-theme youtube-slider">
                <?php if( have_rows('var_youtube') ): ?>
                    <?php while( have_rows('var_youtube') ): the_row(); ?>
                <div>
                        <?= get_sub_field('var_video')?>
                </div>
                    <?php endwhile; ?>
                <?php endif; ?>
                </div>

I use OWL carusel as it is already connected earlier
$('.youtube-slider').owlCarousel({
                loop: true,
                margin: 150,
                nav: true,
                navText: navText,
                dots: false,
                lazyLoad: true,
                items:1,
                responsive:{
                    768:{
                        items:2
                    }
                }
            })

As a result, iframes are displayed in items, but there are a couple of problems: videos run into each other, for some reason the number of items is not set, you can set distances by setting huge margins, but still not that. And most importantly, the videos themselves are somehow strangely displayed for some reason, there is no YouTube icon in the video window at the bottom (to go to the video in YouTube) and when deploying the buttons, they somehow work strangely (pause every other time)
603e383f20539621165466.png
Tell me how to fix it, or maybe how to do to another

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question