Title: Open lightbox via PHP code
Last modified: June 22, 2023

---

# Open lightbox via PHP code

 *  [bonumaster](https://wordpress.org/support/users/bonumaster/)
 * (@bonumaster)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/open-lightbox-via-php-code/)
 * I am using Ajax Load More to retrieve images, How could I use lightbox when images
   are clicked? Help is appreciated. Thanks!
 *     ```wp-block-code
       <div class="alm-gallery-img">
          <a href="<?php echo $image ?>" target="_blank" class="popup">
             <img src="<?php echo $image?>"/ data-lazy="true" style="" class="loaded">
          </a>
       </div>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Arno Welzel](https://wordpress.org/support/users/awelzel/)
 * (@awelzel)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/open-lightbox-via-php-code/#post-16839586)
 * All image links must be processed by the backend which needs to add additional
   data attributes to the <a> element. Just compare that with existing images. The
   minimum attributes needed are:
 * data-lbwps-width – image width in px
   data-lbwps-height – image height in px
 * Without these attributes, the frontend will ignore the link.[](https://arnowelzel.de/wp-content/uploads/2023/04/asus-tuf-gaming-b550-plus.jpg)
 *  Thread Starter [bonumaster](https://wordpress.org/support/users/bonumaster/)
 * (@bonumaster)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/open-lightbox-via-php-code/#post-16839614)
 * Hi. This is the output html
 *     ```wp-block-code
       <a href="https//images.jpg" data-slb-active="1" data-slb-asset="1390835579" data-slb-group="61216" data-lbwps-width="720" data-lbwps-height="720" data-lbwps-srcsmall="https://images.jpg"> 
   
       <img src="https://images.jpg" data-lazy="true" style="" class="loaded"> 
   
       </a>
       ```
   
 * What could we do to make it effective?
   (Images links were removed due to privacy)
 * Thanks for the response.
 *  Plugin Author [Arno Welzel](https://wordpress.org/support/users/awelzel/)
 * (@awelzel)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/open-lightbox-via-php-code/#post-16866224)
 * The code above should be ok. What exactly is your problem? Do you have an example
   website to demonstrate the problem?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Open lightbox via PHP code’ is closed to new replies.

 * ![](https://ps.w.org/lightbox-photoswipe/assets/icon-256x256.png?rev=2906302)
 * [Lightbox with PhotoSwipe](https://wordpress.org/plugins/lightbox-photoswipe/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/lightbox-photoswipe/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/lightbox-photoswipe/)
 * [Active Topics](https://wordpress.org/support/plugin/lightbox-photoswipe/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/lightbox-photoswipe/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/lightbox-photoswipe/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Arno Welzel](https://wordpress.org/support/users/awelzel/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/open-lightbox-via-php-code/#post-16866224)
 * Status: not resolved