6

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

1

1 Answer 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 Oct 22, 2020 at 13:26
  • I've updatet the answer with a working example Oct 23, 2020 at 9:30
  • Thanks, It works fine for me!! Oct 27, 2020 at 3:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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