user1371055
user1371055

Reputation: 25

Add image URL to ACF Gallery images

I have ACF set up in WP with a Gallery field. Currently I am displaying my images as follows:

             <p><?php echo get_the_content(); ?></p> 
                <?php $images = get_field('gallery_images');
                    if( $images ): ?>
                        <div>
                            <ul>
                                <?php foreach( $images as $image ): ?>
                                    <li class="portrait float">
                                        <img src="<?php echo $image['url']; ?>"  />
                                    </li>
                                <?php endforeach; ?>
                            </ul>
                        </div>          
                    <?php endif; 
                ?>

I have also installed the Simple Lightbox Plugin but have been unsuccessful so far. How do I add the URL link of my ACF Gallery images. I have tried wrapping my image tag in a link tag with rel="lightbox" and several other variations including:

     <a href="<?php echo $image_large[0]; ?>"><img rel="lightbox[gallery_images] src="<?php echo $image['url']; ?>"  /></a> 

Is there any way I can enable Attachment Display Settings for my ACF Gallery images in my WP post. I think this might be handy to have?

Any help is much appreciated :)

Upvotes: 0

Views: 2905

Answers (1)

user1371055
user1371055

Reputation: 25

I used the following which worked.

    <a href="<?php echo $image['url']; ?>"><img rel="lightbox[gallery_images]" src="<?php echo $image['url']; ?>"  /></a>

All my images are full size so didn't need the following at all:

    echo $image_large[0];

Upvotes: 1

Related Questions