<?php
/**
 * Copyright © Magefan (support@magefan.com). All rights reserved.
 * Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
 *
 * Glory to Ukraine! Glory to the heroes!
 */
?>
<?php
/**
 * Blog post media gallery images template
 *
 * @var $block \Magefan\Blog\Block\Post\View\Gallery
 */
?>

<?php
    $post = $block->getPost();
    $galleryImages = $post->getGalleryImages();
    $viewFileUrl = $block->getViewFileUrl("Magefan_Blog::css/jquery.fancybox.min.css");
?>

<?php if (count($galleryImages)) { ?>
    <div class="post-gallery clearfix">
        <?php foreach ($galleryImages as $image) { ?>
            <a class="gallery-image-hld"
               data-fancybox="gallery"
               href="<?= $block->escapeUrl($image) ?>"
               rel="nofollow">
                <img class="gallery-image" src="<?= $block->escapeUrl($image->resize(200, 133)) ?>" alt="" />
            </a>
        <?php } ?>
    </div>
    <script>
    require(['jquery', 'domReady!'], function($){
        /* Deferer fancybox css loading */
        $("head").append(
            $("<link rel='stylesheet' href='<?= $block->escapeUrl($viewFileUrl) ?>' type='text/css' media='screen' />")
        );
        /* Deferer fancybox js loading */
        require(['Magefan_Blog/js/jquery.fancybox.min'], function(){});
    });
</script>
<?php } ?>
