diff --git a/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js b/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js index bfd685543d7f7..151c5196db25f 100644 --- a/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js +++ b/app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js @@ -138,10 +138,9 @@ define([ * @private */ _create: function () { - $(this.element).on('gallery:loaded', $.proxy(function () { - this.fotoramaItem = $(this.element).find('.fotorama-item'); - this._initialize(); - }, this)); + $(this.element).data('gallery') ? + this._onGalleryLoaded() : + $(this.element).on('gallery:loaded', this._onGalleryLoaded.bind(this)); }, /** @@ -171,6 +170,14 @@ define([ } }, + /** + * Callback which fired after gallery gets initialized. + */ + _onGalleryLoaded: function () { + this.fotoramaItem = $(this.element).find('.fotorama-item'); + this._initialize(); + }, + /** * Clear gallery events to prevent duplicated calls. *