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

<?php $themeHelperImage = $this->helper('MGS\ThemeSettings\Helper\Image'); ?>
<?php
	$themeSettingConfig = $this->helper('MGS\ThemeSettings\Helper\Config');
	$lazyLoad = $themeSettingConfig->getStoreConfig('themesettings/general/lazy_load');
?>
<?php if($lazyLoad): ?>
	<span class="product-image-container">
		<span class="parent_lazy product-image-wrapper"
			  style="padding-bottom: <?php /* @escapeNotVerified */ echo ($themeHelperImage->getRatio() * 100); ?>%;">
			<img class="product-image-photo lazy"
				 <?php /* @escapeNotVerified */ echo $block->getCustomAttributes(); ?>
				 src="<?= $themeSettingConfig->getImageLazyLoad() ?>"
				 data-src="<?php /* @escapeNotVerified */ echo $block->getImageUrl(); ?>"
				 alt="<?php /* @escapeNotVerified */ echo $block->stripTags($block->getLabel(), null, true); ?>"/></span>
	</span>
<?php else: ?>
	<span class="product-image-container">
		<span class="product-image-wrapper"
			  style="padding-bottom: <?php /* @escapeNotVerified */ echo ($themeHelperImage->getRatio() * 100); ?>%;">
			<img class="product-image-photo"
				 <?php /* @escapeNotVerified */ echo $block->getCustomAttributes(); ?>
				 src="<?php /* @escapeNotVerified */ echo $block->getImageUrl(); ?>"
				 alt="<?php /* @escapeNotVerified */ echo $block->stripTags($block->getLabel(), null, true); ?>"/></span>
	</span>
<?php endif ?>

