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!
In this article, we take a close look at WordPress custom fields and compare them to the custom fields possible with ACF: https://t.co/hk3yibkHyk
— Advanced Custom Fields (@wp_acf) July 14, 2022
© 2022 Advanced Custom Fields.
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.