-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Chrome] Images fully loaded instead of lazy loaded #343
Comments
Experiencing the same error too. |
Hello stephenricks, Are you using height="auto" ? Hope this is understandable and helpfull, |
@stephenricks ? |
Your images are most likely all in the viewport when the page loads. This happens for example when html does not set the dimensions of the image. |
Would you suggest, instead of presizing every images, to move all the lazy loaded images under the floating line (or waterline, sorry I don't know name for the part of the page which is under the bottom line of the viewport) ? |
Giving the images a size using css or image tag is usually the best option. |
I totally agree but, let's say that we have to load +1000 of images from a folder (finally the extrem goal of lazy loading images), some are in landscape, some are in portrait. How would you do that ? Knowing that, if you set a common CSS width or height for both landscape and portrait, portrait images will be displayed bigger. Would you retrieve image size with PHP ? |
If you already use PHP then it would be a good choice. Main point is you need to make sure all your images are not in the viewport when document is loaded. |
Ok and if I don't want to use PHP, there is no other way to retrieve the size instead of using a server side JS solution like node.js (or to read a file with the size for each one)? |
If you want to programmatically retrieve the size of an image file there is no other way than using some programming language to do it. It does not have to be serverside though. It should technically possible fetch the first few bytes of an image and parse the dimensions from there. There is some ancient PHP code for getting remote image dimensions. I am pretty sure someone has done something similar with JavaScript. Doing all this in serverside makes more sense though. After all you want to reduce the traffic and not make an HTTP connection for each image just to get dimensions. |
Yes in the solution I have used (described above) I retrieve the height with PHP:
Then I add to the DOM each image with the height attribute (with a JS processed ratio following the landscape or portrait mode of the picture). I haven't found other solution. Thank you for your explanations @tuupola |
While you are already at it, you could also generate lowres thumbnail of each image and use it as a placeholder. This will create the "blur up" effect. You can see it for example in this example blogpost. Scroll down to see the effect. <img class="lazyload" src="img/example-thumb.jpg" data-original="img/example.jpg" width="765" height="574"> |
I already use a single placeholder ( 1x1 ) but i like the idea, very nice effect. Not sure but I think I have seen something like this on Medium. |
Hello !
Every browser works perfectly fine excepts Chrome who loads all the images, disabling the goal of the plugin.
I am creating the DOM with an Ajax request who read the content of an image folder and then firing the lazyload plugin in order to load only on user scroll (of course !). The images have a given width attribute and a height set on auto. It seems that the issue come from that 'free' size but impossible to fix it keeping the good image ratio.
Do you know where i am wrong? Have you ever seen that issue?
Thanks !
The text was updated successfully, but these errors were encountered: