Duplicate Fully embedded attachments don't show in lightbox if at natural size

nicodak

Well-known member
If anyone is interested in changing how this works, this is how I resolved it:

Code:
<xf:js>
(function ($, window, document, _undefined)
{
    "use strict";

    XF.Lightbox = XF.extend(XF.Lightbox, {
        isImageNaturalSize: function($image)
        {
            return false;
        },
    });
} (jQuery, window, document));
</xf:js>

This will force it to treat all images as displaying at a non-native size, and this function is what's used to determine whether or not to add it to the lightbox. This will make every image in a post be included. A bit of a crude fix but saves editing a core file or re-defining a larger function.
How to implement this ? Which template or file ? Thanks.
 

mattrogowski

Well-known member
I can rationalise the existing logic of only using the lightbox if the image is a thumbnail or has been down-scaled as it enables you to see the full size image, whereas you can already see the full sized image if it's at native size. That makes sense in isolation, however only if it's a lightbox to view a single image. As soon as it starts creating a slideshow of all images in the post or even all images in the thread, it suddenly becomes much more confusing why some are missing. Maybe that is why there's differing opinions as there's slightly different use cases (viewing a slideshow of all images vs simply viewing a single image at full size). I can accept that there would be no benefit in making an image at native size display in a lightbox, but it's designed to show more than one. I don't think using it to view images at full size and using it to browse all images in the post/thread work together with the same logic being applied.

How to implement this ? Which template or file ? Thanks.

If you edit the PAGE_CONTAINER template and put it under <xf:macro template="helper_js_global" name="head" arg-app="public" /> it should work.
 
Last edited:

nicodak

Well-known member
As I explain in the link I posted just above the behavior is even more inconsistent when the images are mirrored with the gallery, you can interact on the reduced photos with the tools that open with the lightbox ( comments, ratings...) and on the photos in full size not...
 

nicodak

Well-known member
If anyone is interested in changing how this works, this is how I resolved it:

Code:
<xf:js>
(function ($, window, document, _undefined)
{
    "use strict";

    XF.Lightbox = XF.extend(XF.Lightbox, {
        isImageNaturalSize: function($image)
        {
            return false;
        },
    });
} (jQuery, window, document));
</xf:js>

This will force it to treat all images as displaying at a non-native size, and this function is what's used to determine whether or not to add it to the lightbox. This will make every image in a post be included. A bit of a crude fix but saves editing a core file or re-defining a larger function.
Hello, this code generate this in the console for each page except home page

Capture d’écran 2022-06-21 104922.png
 

mattrogowski

Well-known member
Not sure why that would be, it's extending core javascript that should be on all pages so shouldn't be anything different between them, and it's the same way javascript is extended elsewhere. It has the same error on the homepage for me too. Most likely something custom on the site conflicting with it.
 

nicodak

Well-known member
Thank you for the answer, I'm not sure I understand correctly: you mean that you have the same errors too on your forum and even on the home page? That's it ? And can this error be corrected?
Or can we leave it like this because it has no effect anywhere? SEO, Page Speed, etc.
Thanks.
 

mattrogowski

Well-known member
No, I meant it's erroring on the homepage of your forum too, as you said it was erroring on all pages expect the homepage. It's fine on the forums I've added this to. It's not going to have any effect on SEO, but I don't know what's causing it to be able to fix it, I can't see how the error is even related to this code, and again doesn't have any issues on any sites I have it on.
 

nicodak

Well-known member
I deactivated all addons and emptying extra.less template and the error still occurs, any idea where i can deeper investigate ?
And i can't see the error in home page, never... :unsure:
 

mattrogowski

Well-known member
Honestly I have no idea, like I say this is how javascript is extended throughout the rest of XF so it's not doing anything different to anywhere else. Try it on a completely stock default theme and go from there I guess.
 
Top