smmj
(Sam)
April 24, 2015, 8:59pm
1
I’m playing around with the ‘lazy load’ plugin and am lost on the correct input for the ‘data-original attribute’ input …(my site is hosted with Webflow)
AlexN
(Alex Nichol)
April 24, 2015, 9:35pm
2
I haven’t done this myself but go to the settings panel of the image add a custom attribute past the “data-original” into the name filed and the image url into the value, with not quotes.
To get the url right click the image in your designer and click copy url. Past this into the value field.
If you are using a webflow sub-domain the url will look something like this;
https://daks2k3a4ib2z.cloudfront.net/551f5133dd9b08957397cf44/552fc4945af5d0db20123d44_example-image-name.png
If you are using a custom domain the url should look something like this.
http://uploads.webflow.com/551f5133dd9b08957397cf44/552fc4945af5d0db20123d44_example-image-name.png
Now I don’t know if it is going to matter that the image will still be referenced with scr="imagesource"
I imagine that it might be a problem.
vlogic
(Robert Henry)
April 25, 2015, 4:55am
3
Here is a tutorial in Tips & Tricks that bartekkustra wrote that uses an alternative class based targeting method. I have not tried it myself.
Continuing the discussion from [Tutorial] How to Implement a Page loader :
Hey Mark,
I’d suggest using LazyLoad jQuery Plugin.
Lazy Load Remastered
There is a whole explanation on that :)
Unfortunatelly it requires to drop the src
parameter from the img
, but you can achieve it in 2 ways:
Use Embed Code
object from library in Webflow - I would not recommend it.
Do it my way.
The LazyLoad Plugin require to use a code like following:
<img class="lazy" data-original="img/example.jpg" width="640" height="480">
where you can set the data-original
parameter. You can set it in Webflow UI, but that will not be efficient, especially that you will need to remember to change it each time the image changes. Oh, and don’t forget to add a class .lazy
to the object you want to lazyload! I’d use a script here that I wrote ;)
$('.lazy').each(function() {
$(this).attr('data-original', $(this).attr('src'));
$(this).removeAttr('src').removeAttr('alt');
});
This nice script of code will find all objects with class .lazy
and loop trough each one of them. It will create a data-original and change its value to the current src
. Right after it’s done it will remove the src
attribute from this object. We are also removing the alt, so the text is not visible as well. Because it is done within $(document).ready()
function images will not load at all, but change to the proper value once the HTML file is processed to browser.
Ok, now… We have to link ourselves to the lazyload javascript file. I’m using my own server, but you can as well just copy&paste its code inside Custom Code. That is not… easy to read, but it will work for now.
A lot of text here, huh? What would you say if I give you a link to video I made during the lazyload installation process? :)
http://quick.as/jgjhowo
As seen on the video above, I’ve did the lazyload on those images. The src
will update to orignal once we hit those images. The threshold:200
parameter we used is to force images to load when the viewport is 200px away from them. That will prevent from “blinking”. At least it should… I’ve just watched the video and I see it got cut off a minute before it should. Anyway, all that was after the cut is I simply refreshed the website and checked that the lazyload works ;)
There are more effects you can use on objects (CLICK HERE to see it in action ). All details about the usage of those can be found on the first link I gave in this post.
Hope it helps :)
Here are links to my webflow site from video
Aaaaand here is the code (beside the paste of lazyload code:
<script>
$(document).ready(function() {
// prepare images to lazyload
$('.lazy').each(function() {
$(this).attr('data-original', $(this).attr('src'));
$(this).removeAttr('src').removeAttr('alt');
});
$('.lazy').lazyload();
});
</script>
Take care :)
@edit the Homer Simpson image is my sister’s drawing for me :P
If you guys want it, here it is :)
Feel free to download it, share it etc! Here is her devianart: http://sashayaross.deviantart.com/
<img src=“//cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/webflow1/original/2X/7/7aef29734fca89378e880f4f4a55c9c4d43406f5.jpg ” width=“690” height=“392”>
1 Like
system
(system)
Closed
May 2, 2015, 4:55am
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.