Home › Forums › Add-ons › Gallery Field › Return Media file not Attachment Page › Reply To: Return Media file not Attachment Page
I found this here and am not sure how to work it into the code you posted above, but it looks to be a good way to get it to link to the image itself in the fancybox/lightbox.
<?php $images = get_field('gallery'); if( $images ): ?> <ul> <?php foreach( $images as $image ): ?> <li> <a class="fancybox" 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; ?>
PS: Edit the above HTML as needed. 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.