jQuery Events

Events fire on the gallery element as name.vpf (and name.vpf-uid-{uid}) with the arguments (event, vpInstance, ...args), and they bubble up to document. When you listen on document, check that event.namespace is vpf.

$( document ).on( 'init.vpf', function ( event, vp ) {
    if ( 'vpf' !== event.namespace ) {
        return;
    }
    console.log( vp.$item.attr( 'class' ) );
} );
EventArguments after the instance
init, initednone
initOptions, initEvents, destroyEvents, initLayout, initCustomColorsnone
imagesLoadednone
resizednone
destroynone
addStyleselector, styles, media, stylesList
removeStyleselector, styles, stylesList
renderStylestylesString, stylesList, $style
addItems$items, removeExisting, $newVP
removeItems$items
startLoadingNewItemsurl, ajaxData
loadedNewItems$newVP, removeExisting, content
endLoadingNewItemsnone

Layout libraries

EventArguments
beforeInitIsotope, initIsotopeoptions
destroyIsotopenone
beforeInitFjGallery, initFjGalleryoptions, additionalData
destroyFjGallerynone
beforeInitSwiperoptions
initSwiperoptions, instance
destroySwipernone
swiperTouchStart, swiperTouchMove, swiperTouchEndswiper, event
beforeInitCustomScrollbar, initCustomScrollbar, destroyCustomScrollbarnone

These events also fire for third-party galleries opened through “Lightbox for WordPress Images”, with null in place of the gallery instance.

EventArguments
beforeInitFancyboxoptions, items, index
initFancyboxoptions, items, index, instance
beforeShowFancybox, afterShowFancybox, beforeCloseFancyboxevent, instance, slide
beforeInitPhotoSwipeoptions, items, index
initPhotoSwipeoptions, items, index, instance
beforeChangePhotoSwipe, afterChangePhotoSwipe, beforeClosePhotoSwipeinstance
destroyPopupGallerynone

Extending the class

extendClass.vpf fires once on document with the gallery class, before any gallery is initialised, so an add-on can extend its prototype.

Was this page helpful?