Image zoom with imageLens. Today we will continue our jQuery tutorials. And today we will talk about image zoom tools. During investigation, I was able to locate imageLens jQuery plugin. This is nice image zooming tool. It looks like round lens and have very easy initialization. Of course, I saw many another libraries too, but they was a little ugly, more like squares than the magnifying glass. I like this plugin, hope that you will like it too. And I sure that this is time to try demo.
Here are samples and downloadable package:
[sociallocker]
[/sociallocker]
Ok, download the example files and lets start coding !
Step 1. HTML
As usual, we start with the HTML. This is source code of our sample:
index.html
01 | <link rel="stylesheet" href="css/main.css" type="text/css" /> |
02 | <script src="js/jquery-1.5.2.min.js"></script> |
03 | <script src="js/jquery.imageLens.js"></script> |
04 | <script src="js/main.js"></script> |
06 | <h3><a href="#">imageLens samples</a></h3> |
07 | <img id="img_01" src="data_images/img1.jpg" width="350" height="262" /> |
08 | <img id="img_02" src="data_images/img2.jpg" width="350" height="262" /> |
09 | <img id="img_03" src="data_images/img3.jpg" width="350" height="262" /> |
10 | <img id="img_04" src="data_images/img4.jpg" width="350" height="262" /> |
As I hope – all clean here, no need explain it. Here are just main page with 4 images inside.
Step 2. CSS
Here are single CSS file with all necessary styles:
css/main.css
1 | body{background:#eee;margin:0;padding:0} |
2 | .example{background:#FFF;width:800px;border:1px #000 solid;margin:20px auto;padding:15px;-moz-border-radius: 3px;-webkit-border-radius: 3px} |
3 | .example img {margin:22px} |
Step 3. JS
Here are all JS files:
js/main.js
1 | $(document).ready(function(){ |
2 | $('#img_01').imageLens(); |
3 | $('#img_02').imageLens({ lensSize: 200 }); |
4 | $('#img_03').imageLens({ lensSize: 200, imageSrc: 'data_images/img5.jpg' }); |
5 | $('#img_04').imageLens({ borderSize: 8, borderColor: '#f00' }); |
Everything is quite easy – when the page loads I perform initialization of imageLens plugin for each image. Each image will have different lens properties. Default lensSize is 100, size – 4, and color – #888. Of course, if you don`t going to use different lens on your set of images and want single – you can just change jquery selector.
js/jquery-1.5.2.min.js and js/jquery.imageLens.js
This is necessary libraries – jQuery and imageLens. Available in our package.
Step 4. Images
All our images located in ‘data_images’ folder:





Conclusion
Today I told you how to implement Lens-looking image zoomer. Sure that you will happy to use it in your projects. Good luck!