Create magnifying glass zoom effect using jQuery magnify Plugin

Create magnifying glass image zoom effect using jQuery magnify Plugin

0 351

You must have seen on many shopping website, You can zoom the product image to see the clear view of design, If you are looking for same effect then here I am going to share jquery plugin to add magnifying glass style zoom functionality to images. Magnify is a simple, lightweight jQuery plugin that adds a magnifying glass style zoom functionality to images. It is a useful feature to have for product images on ecommerce websites, or if you just want people to be able to zoom into an image without spawning additional overlays or popup windows that may cover your content.

Integrate magnifying glass zoom effect on website

Follow below quick steps to integrate magnifying glass style like zoom functionality on images.

Libraries

Include the magnify.css and jquery.magnify.js on along with jquery core library.

<!--CSS-->
<link rel="stylesheet" href="magnify.css">
 
<!--JS-->
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="jquery.magnify.js"></script>

You have complete control over the style and size of the lens by modifying magnify.css. Magnify has support for touch devices, but for a better zoom experience you can load the optional mobile plugin by uncommenting the last line above. It is recommended to load the JavaScript files at the bottom just before the closing </body> tag if possible.

HTML

The URI to the large image can be placed in the data-magnify-src attribute as shown below, or passed as the src option when calling the .magnify() function

<img src="product.jpg" class="zoom" data-magnify-src="product-large.jpg">

If the data-magnify-src attribute or src option is not used, then Magnify will try to grab the large image from the parent &lta> tag. Example:

<a href="product-large.jpg">
  <img src="product.jpg" class="zoom">
</a>

NOTE: The large image needs to have the same aspect ratio as the main image.

Leave A Reply

Your email address will not be published.