• Resolved Dima Stefantsov

    (@dima-stefantsov)


    Hi. I have a page on site where there’s a lot of links like this
    <a href="https://example.org/items#https://s3-eu-west-1.amazonaws.com/s2.example.biz/red_v1/general_photo.png" target="_blank" class="c-button c-button__bigrounded c-button__orange">Download</a>

    Obviously, it’s none of your plugin business, it’s not img src, it’s a hash for a link. But your plugin not just tries to process all this not-images, but also uses
    getimagesize
    on every item it tries to process. Which result in real server-side HTTPS queries to remote resources.

    This is totally not right. Whatever you do, you don’t request remote images on php server side. Do you think you could fix your logic to at least query just local images? More then that, I’d like a plugin that should be able to do it’s stuff on javascript level to not even query any static files from php, accessing HDD operation is usually much slower/costly compared to just processing strings in code.

    There must be a way to somehow output proper code without having to query real HDD image files. If it will result in less optimal display, since you don’t know real image sizes, please make it an option that we can enable/disable.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    Well – there is no simple “yes” or “no” answer to this:

    Why are images loaded at all?

    The way Photoswipe works it must know the image size – otherwise images can’t be displayed in Photoswipe. Also see https://photoswipe.com/documentation/getting-started.html. Also EXIF data can only be determined by loading the image.

    So every image which should be used for the lightbox must be loaded – there is no other way. However – the result (image size, EXIF data etc.) will be cached for at least 24 hours in the database, so not every page request will cause an image load.

    To be able to display remote images lightbox as well was an explizit requested feature by some users and not “totally not right”. Also being able to display images without a thumbnail was an explizit requested feature.

    Why are all links ending with “.jpg”, “.png” etc. are considered to be “images”?

    A link ending with “.png”, “.jpg” etc. will be considered to be an image, because there is no other way to tell if a link refers to an image or not. Without at least trying to load the resource there is no way to find out if it is really an image or not.

    That’s the whole point of Photoswipe: display all linked images on a site within a lightbox. So the links are the relevant item, not any visible image on the page. Because visible images alone can not be clicked to be displayed. The links are what makes images “clickable”.

    A picture gallery works exactly the that way – it outputs links to images.

    Also see here:

    https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe/

    And without visible thumbnails:

    https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe-links-only/

    How to solve your issue?

    I understand there are use cases where links which look like links to an image should be ignored if they don’t contain a visible thumbnail or if the URL in the link refers to another server.

    For the next update I will add an option to ignore links without thumbnails or links to external images and/or links with a specific URL pattern.

    But again: what you describe is a real use case one some websites – some of my users want it exactly this way.

    • This reply was modified 4 years, 4 months ago by Arno Welzel.
    Plugin Author Arno Welzel

    (@awelzel)

    As a quick fix before the next update (see my other reply – held for moderation because I have some links in it, but you may already have noticed it) you can try the following:

    In lightbox-photoswipe.php replace line 493:

    OLD:

    
            if (in_array($type['ext'], ['jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'webp'])) {
    

    NEW:

    
            if (strpos($file, '#')===false && in_array($type['ext'], ['jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico', 'webp'])) {
    

    With this additional check the plugin should not try to load images from URLs which contain a hash sign.

    Plugin Author Arno Welzel

    (@awelzel)

    Release 3.0.6 now provides additional options to ignore links to external sites or links which contain a hash (#) which should solve your problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Your plugin making site really slow’ is closed to new replies.