<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php /** @var $block \Magento\Catalog\Block\Product\Image */ ?>

<?php
$isLazy = true;
if ($block->getCustomAttributes() !== '') {
    $attributeArray = explode(" ", $block->getCustomAttributes());
    foreach ($attributeArray as $attribute) {
        $attributeData = explode("=", $attribute);
        if (count($attributeData) === 2 && isset($attributeData[0]) === true && $attributeData[0] === 'data-nolazy' && $attributeData[1] === '"true"') {
            $isLazy = false;
            break;
        }
    }
}
?>

<div style="max-height:<?= /* @escapeNotVerified */ $block->getHeight() ?>px;">
    <span class="product-image-container"
          style="width:<?= /* @escapeNotVerified */ $block->getWidth() ?>px;">
        <span class="product-image-wrapper" style="padding-bottom: <?= /* @escapeNotVerified */ ($block->getRatio() * 100) ?>%;">
            <div class="product-image-position" style="max-height:<?= /* @escapeNotVerified */ $block->getHeight() ?>px;">
            <?php if ($isLazy === true): ?>
                <img class="product-image-photo lazyload"
                    <?= /* @escapeNotVerified */ $block->getCustomAttributes() ?>
                     src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
                     data-src="<?= /* @escapeNotVerified */ $block->getImageUrl() ?>"
                     width="<?= /* @escapeNotVerified */ $block->getResizedImageWidth() ?>"
                     height="<?= /* @escapeNotVerified */ $block->getResizedImageHeight() ?>"
                     alt="<?= /* @escapeNotVerified */ $block->stripTags($block->getLabel(), null, true) ?>"/>
            <?php else: ?>
                <img class="product-image-photo"
                    <?= /* @escapeNotVerified */ $block->getCustomAttributes() ?>
                     src="<?= /* @escapeNotVerified */ $block->getImageUrl() ?>"
                     width="<?= /* @escapeNotVerified */ $block->getResizedImageWidth() ?>"
                     height="<?= /* @escapeNotVerified */ $block->getResizedImageHeight() ?>"
                     alt="<?= /* @escapeNotVerified */ $block->stripTags($block->getLabel(), null, true) ?>"/>
            <?php endif; ?>
                <div class="image-skeleton"></div>
            </div>
        </span>
    </span>
</div>
