Support » Plugin: Lightbox with PhotoSwipe » Advanced Custom Fields: Gallery Field

  • Resolved nandorsky

    (@nandorsky)


    Hello,

    How would this work with ACF Gallery fields ?
    https://www.advancedcustomfields.com/resources/gallery/

    <?php 
    
    $images = get_field('gallery');
    
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image ): ?>
                <li>
                    <a href="<?php echo $image['url']; ?>">
                         <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                    </a>
                    <p><?php echo $image['caption']; ?></p>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
    

    Thanks.

    • This topic was modified 1 year, 10 months ago by  nandorsky.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    It should work. Did you already try it or what is your support question here?

    Yes, I did try it and it is not working. I’m wondering if I have to add something to this code for it to work. I tried a WordPress basic gallery and it works fine.

    Thanks for your quick reply.

    • This reply was modified 1 year, 10 months ago by  nandorsky.
    Plugin Author Arno Welzel

    (@awelzel)

    I think, the line break my be the problem. Try this:

    <?php 
    
    $images = get_field('gallery');
    
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image ): ?>
                <li>
                    <a href="<?php echo $image['url']; ?>"><img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" /></a>
                    <p><?php echo $image['caption']; ?></p>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Advanced Custom Fields: Gallery Field’ is closed to new replies.