Skip to main content
This page documents the JavaScript API available in Visual Portfolio for frontend customization and integration.

Global Objects

window.VPData

Contains global configuration data localized from PHP. Properties:
  • screenSizes (object) - Responsive breakpoint configuration
  • settingsPopupGallery (object) - Popup gallery settings
  • nonce (string) - WordPress nonce for AJAX requests
  • adminUrl (string) - WordPress admin URL
  • ajaxUrl (string) - WordPress AJAX URL
Example:

window.VPPopupAPI

Global API for popup gallery functionality. Location: assets/js/popup-gallery.js

Properties

  • vendor (string|false) - Current popup vendor name
  • vendors (array) - Array of supported video vendors (YouTube, Vimeo)

Methods

init()
Initialize the popup gallery system.
open()
Open popup gallery with items. Parameters:
  • items (array) - Array of gallery items
  • index (number) - Index of item to open
close()
Close the currently open popup.
getQueryStringParams()
Parse query string parameters from URL. Parameters:
  • query (string) - Query string to parse
Returns: Object with parsed parameters Example:
parseVideo()
Parse video URL and return embed data. Parameters:
  • url (string) - Video URL (YouTube, Vimeo, etc.)
  • poster (string) - Optional poster image URL
Returns: Object with video data or false Example:
parseItem()
Parse gallery item popup data from DOM element. Parameters:
  • itemElement (HTMLElement) - Gallery item element
Returns: Object with parsed item data or false Example:
parseGallery()
Parse all items in a gallery for popup display. Parameters:
  • $gallery (jQuery) - Gallery container element
Returns: Array of gallery items Example:
embedCallback()
Prepare embed data for video. Parameters:
  • vendorData (object) - Video vendor configuration
  • videoId (string) - Parsed video ID
  • url (string) - Original video URL
  • match (object|boolean) - URL match data
Returns: Object with embed data

Layout APIs

Grid Layout

Location: assets/js/layout-grid.js Handles responsive grid layout calculations. Usage:

Masonry Layout

Location: assets/js/layout-masonry.js Provides masonry grid functionality using Isotope.

Slider Layout

Location: assets/js/layout-slider.js Implements carousel/slider functionality using Swiper.

Justified Layout

Location: assets/js/layout-justified.js Creates justified image galleries with consistent row heights.

Tiles Layout

Location: assets/js/layout-tiles.js Generates tile-based layouts with custom patterns.

Custom Events

Portfolio Events

vpf:init

Fired when a portfolio is initialized. Event Detail:
  • vp (object) - Portfolio instance
  • options (object) - Portfolio configuration
Example:

vpf:ready

Fired when a portfolio is fully loaded and ready. Example:

vpf:layoutReady

Fired when portfolio layout is calculated and rendered. Example:

vpf:imagesLoaded

Fired when all images in portfolio are loaded. Example:

Filter Events

vpf:filterChange

Fired when filter selection changes. Event Detail:
  • vp (object) - Portfolio instance
  • filter (string) - Selected filter value
Example:

Pagination Events

vpf:loadMoreStart

Fired before loading more items. Example:

vpf:loadMoreComplete

Fired after loading more items completes. Example:

vpf:popupOpen

Fired when popup gallery opens. Event Detail:
  • vp (object) - Portfolio instance
  • popup (object) - Popup instance
  • index (number) - Current item index
Example:

vpf:popupClose

Fired when popup gallery closes. Example:

jQuery Events

Portfolio Initialization

Layout Events

Filter Events


Extending Functionality

Adding Custom Video Vendors

You can add support for additional video platforms by extending the VPPopupAPI.vendors array. Example:

Custom Lazy Loading Behavior

Disable lazy loading for specific images:

Accessing Portfolio Instance

Via jQuery:
Via vanilla JavaScript:

Integration Examples

Google Analytics Tracking

Custom Loading Indicator

Lazy Load Callback