• Resolved Michael Nelson

    (@mnelson4)


    When I use the foo gallery that lazy loads the images, it works great when viewed online, but not great when I print the page (eg to ye old paper).
    Eg, if a post has a foo gallery towards the bottom, if I print the post from my browser without scrolling down, the foo gallery is images won’t appear in the printout. I need to scroll down, then print, in order for them to be visited in the printout.
    Is there anything that can be done to make sure images always appear when printing a post using foo gallery? (Besides making the images not lazy load, because that’s usually a nice feature).
    Or is there any javascript I can execute to force all the lazy-loading images to load?

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

    (@bradvin)

    Hi Michael,

    You might be able to run some JS before the print. Looking at this article, it does seem possible : https://stackoverflow.com/questions/11138939/how-to-trigger-javascript-on-print-event

    @steveush please can you chime in here with some code to force FooGallery to load all images as if the visitor had scrolled down to the gallery

    Plugin Author steveush

    (@steveush)

    Hi @mnelson4,

    I’ve taken a look at this and it is not something I think is possible. A solution could be cobbled together but it would not work 100% across all browsers or even 100% of the time in the same browser. The answer to this Stack Overflow question lists the reasons why but to summarize them:

    1. Hooking into the onbeforeprint event and forcibly loading the images will not guarantee that they have actually loaded before the browser takes the snapshot to print. Images are loaded asynchronously so once the load is triggered the browser will immediately snapshot the page and print what is available without waiting for the images to finish.

    2. You can’t stop/stall the print request from the browser. We do not have this kind of control over the browser when working with client side scripts other wise the web would be a lot more dangerous to navigate. There are ways to try and stall it but they all involve JavaScript that is not recommended as it basically hangs the browser to perform the stall.

    I’ll add a story for this to our backlog that we can keep checking in on in the future but at present I don’t believe a viable option that could be added into the core code exists. All solutions I have seen require custom Print buttons within the page which kind of defeats the whole point as most people will use the browsers print feature.

    Thanks

    Thread Starter Michael Nelson

    (@mnelson4)

    Thanks for looking into it @steveush, that sounds reasonable. Is there at least a way to tell foo gallery to load all the images immediately (rather than delay)? Eg on certain pages I know users will want to print, I could override the dynamic gallery’s default behavior of lazy-loading the images.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Printing responsive galleries’ is closed to new replies.