Support » Plugin: Lightbox with PhotoSwipe » Required data attributes on link

  • Thanks for the great plugin!

    Just a piece of information that might be useful for others: in order to work, it appears to be mandatory that the link tag includes a “data-width” / “data-height” attribute.

    So for instance, an image link formatted like this won’t trigger the lightbox:

    
    <a href="large.jpg"><img src="thumb.jpg"/></a>
    

    In order to work, something like this is required:

    
    <a href="large.jpg" data-width="1200" data-height="800"><img src="thumb.jpg"/></a>
    

    I needed to figure this out in order to use the plugin with a custom theme I’m developing.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Here’s a piece of code I used to build the link with the data attributes:

    
    $myprefix_img = wp_get_attachment_image_src(
      $id, 
      'full' 
    );
    								
    echo '<a href="'.$myprefix_img[0] .'" data-width="'.$myprefix_img[1] .'" data-height="'.$myprefix_img[2] .'">'; 
    
    Plugin Author Arno Welzel

    (@awelzel)

    Normally my plugin will add these attributes itself. If this does not work for you without adding the attributes in the theme, then there may be a conflict in your themes code. If you like to, you can give me your theme and I’ll check what’s wrong. You find my e-mail address on my website: https://arnowelzel.de/en/about-me

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Required data attributes on link’ is closed to new replies.