0

I'm currently building a small PHP photo gallery system using lightbox. My code:

<div class="col-7 offset-2 p-2">
  <a href="uploads/entrance.jpg" data-lightbox="gallery"><img src="uploads/entrance.jpg" alt=""></a>
  <?php foreach ($photos as $photo){?>
              <a  class="gone" href="<?php echo $photo->file_path('uploads',$photo->filename)?>" data-  lightbox="gallery"><img src="<?php echo $photo->file_path('uploads',$photo->filename)?>" alt=""></a>
  <?php } ?>
</div>

I wish to show the first indexed/id photo as the thumbnail/cover image. Once the user wishes to view the gallery, they can click the image and lightbox launches allowing a preview of the photos drawn from SQL.

How do I achieve this?

This may be quite an amateur question, but I'm meddling around with what I've learnt from youtube :P

tereško
  • 58,060
  • 25
  • 98
  • 150
Ballan
  • 9
  • 3
  • You'll need to build a custom ajax handler that you'll call when the user opens up lightbox. That handler would then go to a PHP class that handles the SQL and returns the data you need. – demitchell14 Mar 07 '18 at 01:51
  • You could create links for all your images, but make visible only the first one. See the last example here - https://codepen.io/fancyapps/pen/mqEMGX?editors=1000 – Janis Mar 11 '18 at 20:01

0 Answers0