Front-End Image Preview For Mobile-Web Applications | imagePreview

Mobile JS photo preview plug-in supports rotation and zoom (two fingers / double click), and comfort and smoothness is the biggest pursuit.

ImagePreview is an iOS-style, mobile-first, super smooth image viewer written in JavaScript.


  • Zoom in / out with fingers.
  • Allows you to rotate images.
  • Switch between images with a swipe.

Must Read: A Simple File Upload That Shows A Preview of the Uploaded Image

How to make use of it:

1. Download and import the imagePreview JavaScript library.

<script src="./release/image-preview/image-preview-iife.js"></script>
// OR as an ES module
import {ImagePreview} from './release/image-preview/image-preview-esm.js'

2. Initialize the ImagePreview in your photographs.

<div class="gallery">
  <img data-src="large.jpg" src="small.jpg" alt="Image 1" />
  <img data-src="large.jpg" src="small.jpg" alt="Image 2" />
  <img data-src="large.jpg" src="small.jpg" alt="Image 3" />
new imagePreviewModule.ImagePreview({
    selector:'.gallery img'

3. Or add photographs to the image viewer through JavaScript.

let imgViewer =  new ImagePreview({
// then show an image;

4. Destroy.



  • new ImagePreview({imgs?: Array<string|HTMLImageElement>})
  • new ImagePreview({selector?: string}) Generate an ImagePreview instance.
  • Open index-th img on imagepreivew, index starts from 0.
  • imagePreview.prototype.insertImageAfter( image: string | HTMLImageElement , index: number ) Insert a new image after the index, if the index < 0, then a new image will be inserted at the 0 positions. If the index is greater than imgs’ length, the new image will be inserted in the last position.
    • Note: If the param image is HTMLImageElement, and it is cross-origin, you’d better set the crossOrigin attribute.
  • imagePreview.prototype.delImage(index:number) Delete index-th image. The index below 0 is 0, and greater than imgs’s length will be set to the last index.
  • imagePreview.prototype.destroy() Destroy image preview instance. Remove HTML generated by this ImagePreview instance and other resources. For better performance, then you can set imgObj = null;

See Demo And Download


Official Website(daxiazilong): Click Here

This superior jQuery/javascript plugin is developed by daxiazilong. For extra Advanced usage, please go to the official website.

Related Posts


CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…


How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…


Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…


Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…


Bootstrap 4 Sidebar Menu Responsive Template | MDB

Bootstrap Side Navbar – Responsive sidebar template based on the Bootstrap 4 framework. An easy-to-use, totally responsive, Google Material Design impressed aspect navigation for modern web app…


Lightweight Bootstrap 4 Toast Notification Plugin | BS4 Advanced Toast

A lightweight Bootstrap 4 Toast Notification plugin integrated with JS/jQuery. bs4-toast.js is a JavaScript library that enhances the native Bootstrap toast component with icons, buttons, callbacks, and…

Leave a Reply

Your email address will not be published. Required fields are marked *