Support

Account

Home Forums Add-ons Gallery Field Add videos on ACF Gallery

Solving

Add videos on ACF Gallery

    • tannan

    • June 18, 2018 at 8:04 pm

    Hello,

    I use ACF Gallery for my portfolio website and I would like to add some videos in this gallery. I want to keep the possibility to manage the order of my medias, to mix videos and images. I’m not sure if I can add video between my images with the ACF Gallery plugin. How can I do ?

    The current code I use for my gallery :

                <div class='gallery'>
    
                <?php 
    
                $images = get_field('images_projet');
    
                if( $images ): ?>
                    <?php foreach( $images as $image ): ?>
                        <?php $pb = $image['height'] / $image['width']; ?>
    
                        <div class="img-wrapper">
                            <div class="pb" style="padding-bottom: <?= $pb * 100 ?>%;"></div>
                            <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
                        </div>
                        <?php echo $image['caption']; ?>
                    <?php endforeach; ?>
                <?php endif; ?>
    
            <div>

    Thank you
    N.

  • The ACF Gallery field does images only.

    For a mixed gallery of any kind I would suggest using a repeater field with a selection for what type of media and then conditional fields for images and other media types based on this.

    • tannan

    • June 19, 2018 at 8:30 pm

    Thank you for you answer. Sorry, I’m a beginner.

    I added two different repeaters, one for my images, and one for my videos. How can I to the conditional fields after that ?

    Thank you again.

  • In order to loop over them and put them in the right order you will need 1 repeater.

    Then you create a radio field to select media type, for example image or video.

    Then you create a field for adding a video and set the conditional logic to only show when video is selected as media type and an image field that is only shown if image is selected.

  • Hey, do you plan to add support for video in the gallery field? Would be greatly appreciated. All of these workarounds are kind of annoying.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.