Skip to main content

Magento2 gallery afterLoad callback

If you need to do any JavaScript  code after Magento gallery is loaded you can use this event in your code

<script type="text/javascript">
    require(['jquery', 'mage/gallery/gallery'], function($, gallery){
        $('[data-gallery-role=gallery-placeholder]').on('gallery:loaded', function () {
          // write your code here
        });
    });
</script>

it is the best code that i used, I hope this will help you