Lightbox helper


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. function lightbox($image,$title='',$ext='jpg',$thumbext='jpg') {
  4. $domain = 'http://example.com/';
  5. $alt = ' alt=""';
  6. if( ! $title=='') {
  7. $alt=' alt="'.$title.'"';
  8.  
  9. $title = ' title="'.$title.'"';
  10. }
  11. echo '<a'.$title.' rel="lightbox" href="'.$domain.'gallery/'.$image.'.'.$ext.'"><img src="'.$domain.'gallery/'.$image.'_thumb.'.$thumbext.'" /></a>';
  12. }
  13.  
  14. /*
  15.  
  16.  ---USING---
  17. put images to gallery folder
  18. 1.jpg, 1_thumb.jpg, 2.jpg, 2_thumb.jpg ...
  19. then in php u can do this:
  20.  
  21. <ul class="images">
  22. <li><?php lightbox('1'); ?></li>
  23. <li><?php lightbox('2'); ?></li>
  24. <li><?php lightbox('3'); ?></li>
  25. <li><?php lightbox('4'); ?></li>
  26. </ul>
  27.  
  28. */

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.