Extensions Authoring Guide
Extensions are objects that implement the VistaExtension interface and hook into the lightbox lifecycle. You pass them in the extensions array when initializing VistaView, and they can add UI controls, respond to navigation events, replace image rendering with custom content, and more.
The VistaExtension Interface
Section titled “The VistaExtension Interface”Quick Start
Section titled “Quick Start”The minimal extension — just a name and one hook:
Extension Types
Section titled “Extension Types”There are three patterns, each covered in its own guide:
UI Extensions
Section titled “UI Extensions”Add a button or other control element to the toolbar. The control() method returns the element; you register it in the controls config by the extension’s name.
Use onDeactivateUi / onReactivateUi to respond when other extensions disable controls (for example, video extensions disable zoom and download).
Behavior Extensions
Section titled “Behavior Extensions”React to lifecycle events without any visible UI — logging, analytics, keyboard shortcuts, auto-play, etc. These only use the on* hooks.
Content Extensions
Section titled “Content Extensions”Intercept onInitializeImage and return a custom VistaBox subclass to replace the default image renderer. Used for videos, maps, iframes, or any non-image content.
Lifecycle Event Order
Section titled “Lifecycle Event Order”On open
Section titled “On open”onOpen(all extensions)onInitializeImage(per image, for preloaded images)onImageView(for the initial image)
On navigate
Section titled “On navigate”onInitializeImage(for newly preloaded images)onImageView
On close
Section titled “On close”onClose(all extensions)
Using Extensions with Controls
Section titled “Using Extensions with Controls”If your extension provides a control(), register it by name in the controls configuration:
The extension name and the string in the controls array must match exactly.
Next Steps
Section titled “Next Steps”- UI Extensions — add buttons and toolbar elements
- Behavior Extensions — hook into events without UI
- Content Extensions — render custom content types
- Built-in Extensions — see real examples