question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make img thumb and then load larger img

See original GitHub issue

First of all thank you for the script. It is by far the best medium like zoom that I’ve seen, UX wise.

But the way it’s structured with just one huge scaled image makes it bad for mobile and Google Page Speed does not like it at all.

How about changing the html structure so that a smaller image is displayed first and then load the high resolution image on click in the overlay? The thumb could be displayed big in the overlay until the high-res has loaded.

Something along the lines of

<a class="medium-zoom-image" href="images/1-jumbo.jpg">
<img src="images/1.jpg" alt="Medium Zoom illustration" class="medium-zoom-thumb">
</a>

EDIT Or using an attribute for the high res like so:

<img src="images/1.jpg" data-hd="images/1-jumbo.jpg" alt="Medium Zoom illustration" class="medium-zoom-thumb">

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
francoischalifourcommented, May 3, 2017

Hi, thank you for getting involved. Your issue is somehow related to #3 (they both aim at solving the same problem).

I like your second solution better. My first view on this would be to:

  1. Load the data-hd URL on the event show (when the user clicks on the image)
  2. Set the src attribute to the data-hd’s value on shown* (when the image is fully zoomed in)
  3. Reset the src attribute on hide or hidden (see which one is more coherent)

(*) It might be more relevant to detect when the image is fully loaded instead of relying on the shown event to not show a partial image. That means attaching a load event to the newly created data-hd image.

What’s your view on this?

0reactions
francoischalifourcommented, Sep 30, 2017

Fixed with #21.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Load big size images as thumb - php - Stack Overflow
Hi I'm working with project that upload images as attachment everything working cool except that when I upload image from mobile its like...
Read more >
How to resize an image in HTML? - ImageKit.io
If the image element's required height and width don't match the image's actual dimensions, then the browser downscales (or upscale) the image.
Read more >
How to Resize Images in HTML - Quackit Tutorials
To resize an image in HTML, use the width and height attributes of the img tag. You can also use various CSS properties...
Read more >
Responsive images - Learn web development | MDN
Load the image referenced in the srcset list that has the same size as the slot or, if there isn't one, the first...
Read more >
Bootstrap Images - W3Schools
Create responsive images by adding an .img-responsive class to the <img> tag. The image will then scale nicely to the parent element. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found