• Resolved noban

    (@noban)


    Hi, I’m sorry to bother you, it’s probably something really stupid on my end. I’m not really experienced when it comes to wordpress coding.

    I was asked with improving my uncle’s website and in particular photo galleries which were running on old prettyPicture. I tried installing photoswipe directly and it didn’t work and after I found this plugin, still doesn’t work.

    I have this code, which works in a way that displays one large image on the left half and the rest as thumbnails on the right side, but when I click them, it takes me to the picture media url and doesn’t open the lightbox.

    Can you help me please?


    “>

    • This topic was modified 4 weeks ago by noban.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter noban

    (@noban)

    <div class="nemovitost-galerie">
    <div class="nemovitost-galerie__featured">
    <?php
    $featured_full = get_the_post_thumbnail_url( $property, 'full' );
    $featured_large = get_the_post_thumbnail_url( $property, 'medium_large' );
    $image_caption = get_post(get_post_thumbnail_id())->post_excerpt; // Get image caption for PhotoSwipe
    ?>

    <a href="<?php echo $featured_full; ?>" data-size="1600x1067" data-pswp-uid="1" data-lbwps-gid="gallery-1"> <!-- Added data-lbwps-gid -->
    <img src="<?php echo $featured_large; ?>" alt="<?php echo esc_attr( get_the_title() ); ?>">
    </a>
    </div>

    <div class="nemovitost-galerie__thumbs">
    <?php
    $counter = 1; // Start counter for image UIDs
    foreach( $property->fotografie as $attach_id => $foto ) {
    if( $attach_id == get_post_thumbnail_id( $property->ID ) ) continue; // Skip featured photo

    $counter++;
    $size = $foto['medium'];
    $url = $size[0];
    $large_image_url = wp_get_attachment_image_src( $attach_id, 'full' );
    ?>

    <a href="<?php echo $large_image_url[0]; ?>" class="nemovitost-galerie__thumb <?php echo $counter > 9 ? 'nineplus' : ''; ?>" data-pswp-uid="<?php echo $counter; ?>" data-lbwps-gid="gallery-1"> <!-- Added data-lbwps-gid -->
    <img src="<?php echo $url; ?>" alt="<?php echo esc_attr($property->post_title); ?>" />
    </a>

    <?php
    }
    ?>
    </div>
    </div>
    Plugin Author Arno Welzel

    (@awelzel)

    I’m sorry, but I can not really help here. The result of this code should be ok – but it may be, that this code runs after the output buffer for the current request was already handled. I could not tell it without having a look to the complete website installation and a debugger for it. But this is out of scope in this support forum, sorry.

    Thread Starter noban

    (@noban)

    I understand. I’ll try dig into it and not break it any more.
    One of the pages with the gallery is:
    https://www.bohunekvankova-reality.cz/nemovitost/prodej-bytu-31-81-m2-pohled/

    Plugin Author Arno Welzel

    (@awelzel)

    Your problem is not the HTML code. You use some kind of “JavaScript optimizer”. Don’t do this – or if possible exclude Lightbox with PhotoSwipe from it.

    Modular JavaScript (which PhotoSwipe uses for good reasons) will usually get damaged by “optimizers” and using these optimizers nowadays is mostly useless, since HTTP/2 (which your website uses as well) uses methods to avoid additional turnarounds when requesting many single resources. So it makes no big difference if you have 1 or 20 JavaScript files to load since all will be loaded with only one single connection which gets reused until all resources got loaded for the current URL.

    And for the future: if you experience any problems – disable ALL caching and ALL “optimizer” first! Only then you will see, if there is any issue with your code and not just a side effect caused by any caching or optimizing plugins.

    • This reply was modified 3 weeks, 5 days ago by Arno Welzel.
    Thread Starter noban

    (@noban)

    Thank you for Your advice. I’ll investigate.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.