
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
hpv-image-previewer
Advanced tools
Hyper Parametrizable Vanilla image previewer, the best independent image preview tool.
A standalone, extensible JavaScript class for displaying images or galleries in a modal overlay with advanced zoom, pan, navigation, and custom action capabilities. Fully responsive, event-driven, and easily integrated into any web project.
Modal overlay with gallery navigation
Zoom and pan controls in action
Gallery carousel with thumbnails
Fully responsive on desktop and mobile
<link rel="stylesheet" href="src/css/main.css">
<script src="src/js/main.js"></script>
const previewer = new HpvImagePreviewer({
closeButtonText: 'Close',
isReadOnly: false,
buttons: [
{
id: 'view',
label: 'View',
title: 'View full size image',
customClasses: ['btn-primary'],
visibleReadOnly: true,
clickHandler: (image) => window.open(image.url, '_blank')
},
{
id: 'star',
label: 'Star',
title: 'Mark as favorite',
customClasses: ['btn-star'],
keyPress: { key: 's', shift: true }, // Triggers with Shift+S
clickHandler: (image) => alert('Starred: ' + image.alt)
}
]
});
const imageModel = { url: 'path/to/image.jpg', alt: 'Description' };
previewer.show(imageModel);
const images = [
{ url: 'img1.jpg', alt: 'First' },
{ url: 'img2.jpg', alt: 'Second' }
];
previewer.showGallery(images, 0); // Start at first image
| Option | Type | Default | Description |
|---|---|---|---|
buttons | Array | [] | Array of custom button configs |
closeButtonText | string | 'Close' | Text for the close button |
isReadOnly | boolean | false | If true, only shows buttons with visibleReadOnly: true |
minScale | number | 1 | Minimum zoom scale |
maxScale | number | 5 | Maximum zoom scale |
onClose | function | null | Callback for close button click |
onImageSwitch | function | null | Callback for gallery navigation |
isDebug | boolean | false | Enable debug logging |
| Property | Type | Required | Description |
|---|---|---|---|
id | string | âś… | Unique identifier |
label | string | âś… | Button text |
title | string | ❌ | Tooltip text |
icon | string | ❌ | CSS class for icon |
visibleReadOnly | boolean | ❌ | Show in readonly mode (default: true) |
customClasses | Array | ❌ | Extra CSS classes for styling |
clickHandler | function | âś… | Called on click: (image, previewerInstance) => {} |
keyPress | Object | ❌ | Keyboard shortcut: { key: 'd', ctrl: true } |
{
url: 'string', // Required: Image URL
alt: 'string', // Optional: Alt text
file: File, // Optional: Original file object
// ...any custom properties
}
show(imageModel)showGallery(galleryImages, activeIndex = 0)navigateGallery(direction)hide()updateOptions(newOptions)toggleReadOnly()setReadOnly(isReadOnly)destroy()| Event Name | Detail Payload | Description |
|---|---|---|
hpvImagePreviewer:customButtonClick | { buttonId, image, button } | Custom button clicked |
hpvImagePreviewer:close | { image } | Overlay closed |
hpvImagePreviewer:navigate | { currentImage, currentIndex, previousImage, galleryLength, direction, cycled } | Gallery navigation occurred |
src/js/
main.js # HpvImagePreviewer class
src/css/
main.css # Overlay/modal/gallery styles
src/index.html # Sample usage
examples/
image-previewer-standalone.html # Advanced example
docs/
HpvImagePreviewer-README.md # Full documentation
MIT
Pull requests and issues are welcome! Please see docs/HpvImagePreviewer-README.md for full documentation and advanced usage.
FAQs
Hyper Parametrizable Vanilla image previewer, the best independent image preview tool.
The npm package hpv-image-previewer receives a total of 5 weekly downloads. As such, hpv-image-previewer popularity was classified as not popular.
We found that hpv-image-previewer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.