Click here to Skip to main content
15,885,985 members
Articles / Web Development / HTML
Tip/Trick

JQzoom Image magnifier for Zooming Image

Rate me:
Please Sign up or sign in to vote.
4.83/5 (5 votes)
14 May 2014CPOL1 min read 30.2K   1.5K   7   3
In this trick we are going to see image magnifying effect as seen on many e-commerce websites

In many e-commerce site (like flipkart,myntra etc), we have seen image zooming effect on mouse hovering the product image. In this article, we are going to see How to use JQZoom plugin for adding zoom effect to images.

Let's Start:

Firstly, Go to http://www.mind-projects.it/projects/jqzoom/ and Download the JQZoom plug-in. Extract the Files and copy js and css folder to the root directory of you project. In the Head tag of your webpage add Jquery and JQZoom plugin script. You can also attach the latest CDN from jquery site rather than using jquery-1.6.js version of jquery. Add jquery.jqzoom.css file in head tag.

HTML
<script src="js/jquery-1.6.js"></script>
<script src="js/jquery.jqzoom-core.js"></script>
<link href="css/jquery.jqzoom.css" rel="stylesheet" /> 

In this Example, I am going to use two jpeg images(one small thumbnail and one bigger).One Important thing is that the small picture(i.e. bikethumb.jpg) which is ging to be used as thumbnail is the scaled version of larger Image. Basically we want that on mouse hovering the small image larger image appear. And we are going to use class="minipic" in JQZoom script.

HTML
<a href="images/bike.jpg" class="minipic" title="Cartoon Bike"><img src="images/bikethumb.jpg" title="Bike"/></a>

Now we have to add another script tag which is used to call jqzoom function. We have passed some parameter in jqzoom function like zoomtype for type on effect on mouse hover the small pic.There are 6 types of ZoomType effect which we can use. Here we set lens true so that lens become visible on mouse hovering the small pic(i.e. bikethumb). We can also adjust zoom width and zoom height of the Magnified image.

Image 1

JavaScript
<script type="text/javascript">
            $(document).ready(function () {
                $('.minipic').jqzoom({
                    zoomType: 'standard',
                    lens: true,
                    preloadImages: false,
                    alwaysOn: false,
                    zoomHeight: 200,
                    zoomWidth:200
                });
            });
</script>
Final Preview:
Image 2

Hope you like it. Thanks

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
India India

Comments and Discussions

 
Questionjquery conflict Pin
Member 1416453527-Feb-19 0:55
Member 1416453527-Feb-19 0:55 
GeneralMy vote of 4 Pin
buyi.xiaohan15-May-14 16:28
buyi.xiaohan15-May-14 16:28 
GeneralRe: My vote of 4 Pin
Anoop Kr Sharma15-May-14 19:23
professionalAnoop Kr Sharma15-May-14 19:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.