6

I want to add and play custom video where product images are display. Can any one help me?

1
1
<script>
    require([
        'jquery',
        'mage/gallery/gallery',
    ], function ($) {
        
        $('[data-gallery-role=gallery-placeholder]').on('gallery:loaded', function () {

            // $(this).on('fotorama:ready', function () {

            var api = $(this).data('gallery');

            var video = {
                id: 'ZpFrNyD4100',
                source: 'youtube',
                caption: 'Magento Commerce'
            }

            api.fotorama.data.push({
                video: {
                    id: video.id,
                    p: 'https://',
                    s: '',
                    type:  video.source,
                },
                isMain: false,
                type: 'video',
                caption: video.caption
            });
            // });
        });
    });
</script>

For reference:

3
  • I have followed this method, i got "Uncaught ReferenceError: video is not defined at images.js:3120 " this error. Can you please let me know where you defined 'video'? please check my code, nimb.ws/YsG1UL – Sunny Rahevar Oct 22 '20 at 13:26
  • I've updatet the answer with a working example – Stevie-Ray Hartog Oct 23 '20 at 9:30
  • Thanks, It works fine for me!! – Sunny Rahevar Oct 27 '20 at 3:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.