user5662592
user5662592

Reputation:

Lightbox ACF repeater single image

I have some repeater field in ACF with a single image. Thease images have to have a lightbox. It doesn't work by default.

I know, slb activate(), have to be activated. I can find howto's on how to do this for a gallery in ACF, but not for a single image in an ACF repeater.

Here's my code:

 <?php elseif(get_row_layout() == "verdiepingen"): ?>
 <?php if( have_rows('verdiepingen') ): ?>
 <?php while( have_rows('verdiepingen') ): the_row();       
 // vars
 $image = get_sub_field('afbeelding_verdieping');
 $content = get_sub_field('content_verdieping');
 $plattegrondlinks = get_sub_field('plattegrond_verdieping_links');
 $plattegrondrechts = get_sub_field('plattegrond_verdieping_rechts');         $penthouse 
 ?>

 <img src="<?php echo $plattegrondlinks['url']; ?>" alt="<?php echo $plattegrondlinks['alt'] ?>" class="img-responsive" />

Upvotes: 0

Views: 692

Answers (1)

Rob Pod
Rob Pod

Reputation: 11

Hello quinox,

I may be wrong but I believe you need to wrap your image with anchor link to the image which should be opened in Lightbox. So your HTML inside the loop should look somehow like this:

<a href="<?php echo $plattegrondlinks['url']; ?>" title="Lightbox link - please check documentation of Lightbox" class="lightbox">
    <img src="<?php echo $plattegrondlinks['url']; ?>" alt="<?php echo $plattegrondlinks['alt'] ?>" class="img-responsive" />
</a>

Consider placing smaller image on the preview - your page will load faster. Let me know if that helps.

Upvotes: 1

Related Questions