Data Attributes
VistaView uses data attributes to customize how images are displayed in the lightbox. These attributes provide fine-grained control over individual images without requiring JavaScript configuration.
Available Attributes
Section titled “Available Attributes”| Attribute | Description | Priority |
|---|---|---|
data-vistaview-src | Full-size image URL | Highest |
data-vistaview-srcset | Responsive image srcset | Highest |
data-vistaview-alt | Alt text for lightbox | Highest |
Attribute Priority
Section titled “Attribute Priority”VistaView follows a specific priority order when parsing elements:
Image Source (src)
Section titled “Image Source (src)”data-vistaview-src(highest priority)hrefattribute (for<a>tags)srcattribute (on the element itself)srcattribute (on child<img>tag)
Responsive Images (srcset)
Section titled “Responsive Images (srcset)”data-vistaview-srcset(highest priority)srcsetattribute (on the element itself)srcsetattribute (on child<img>tag)
Alt Text (alt)
Section titled “Alt Text (alt)”data-vistaview-alt(highest priority)altattribute (on the element itself)altattribute (on child<img>tag)
Examples
Section titled “Examples”Basic Override
Section titled “Basic Override”Override the lightbox image URL while keeping the thumbnail:
Responsive Images
Section titled “Responsive Images”Provide different images based on the displayed image size. VistaView dynamically selects the most appropriate image as the image size changes:
How it works:
- VistaView monitors the image’s display width (not viewport width) and automatically switches to the optimal image from the srcset
- The image display width depends on the viewport and the image’s aspect ratio (portrait images are constrained by height, landscape by width)
- Accounts for device pixel ratio (DPI) for high-resolution displays (e.g., Retina screens)
- Selects the smallest image that meets or exceeds the required display width
- Dynamically swaps images during opening animation and zoom gestures
Format: "url {width}w, url {width}w, ..." where width descriptors specify the image’s actual pixel width.
Example with pixel calculations:
Custom Alt Text
Section titled “Custom Alt Text”Display different text in the thumbnail vs lightbox:
Combining Attributes
Section titled “Combining Attributes”Use multiple attributes together. When both src and srcset are provided, srcset takes precedence and src serves as fallback:
Priority order: If srcset is available, VistaView uses responsive selection. The src attribute (or data-vistaview-src) is used only when srcset is not provided.