Magento 2 Free Quick Cloud Zoom Extension di .xml not getting override
this is app/code/Ibnab/CloudZoomy/etc/frontend/di.xml
----------
this is phtml app/code/Ibnab/CloudZoomy/view/frontend/templates/product/view/gallery.phtml
getConfigValue('ibnab_cloud_config/general/enabledisable');
$jsonGallery = $block->getGalleryImagesJson();
$arrayJsonGallery = json_decode($jsonGallery, true);
$useragent=$_SERVER['HTTP_USER_AGENT'];
if($typeGallery == 1 && !preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4))):
?>
" class = 'cloud-zoom' id='zoom1'rel="" >
" title="" />
' class='cloud-zoom-gallery' title='Thumbnail '
rel="useZoom: 'zoom1', smallImage: '' ">
" alt = ""/>
<script>
require([
'jquery',
'ibnabzoom',
'mage/apply/main',
'galleryList'
], function ($, ibnabzoom, mage, gallery) {
});
</script>
getViewFileUrl('images/loader-1.gif'); ?>"
alt="">
var config = {
"width": getImageAttribute('product_page_image_medium', 'width'); ?>,
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"height": getImageAttribute('product_page_image_medium', 'height'); ?>
},
thumbBarHeight = 0,
loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];
if (config.navtype === 'horizontal') {
thumbBarHeight = config.thumbheight;
}
loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
{
"[data-gallery-role=gallery-placeholder]": {
"mage/gallery/gallery": {
"mixins":["magnifier/magnify"],
"magnifierOpts": getMagnifier(); ?>,
"data": getGalleryImagesJson(); ?>,
"options": {
"nav": "getVar("gallery/nav"); ?>",
getVar("gallery/loop"))): ?>
"loop": getVar("gallery/loop"); ?>,
getVar("gallery/keyboard"))): ?>
"keyboard": getVar("gallery/keyboard"); ?>,
getVar("gallery/arrows"))): ?>
"arrows": getVar("gallery/arrows"); ?>,
getVar("gallery/allowfullscreen"))): ?>
"allowfullscreen": getVar("gallery/allowfullscreen"); ?>,
getVar("gallery/caption"))): ?>
"showCaption": getVar("gallery/caption"); ?>,
"width": "getImageAttribute('product_page_image_medium', 'width'); ?>",
"thumbwidth": "getImageAttribute('product_page_image_small', 'width'); ?>",
getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
getImageAttribute('product_page_image_medium', 'height') || $block->getImageAttribute('product_page_image_medium', 'width')): ?>
"height": getImageAttribute('product_page_image_medium', 'height')
?: $block->getImageAttribute('product_page_image_medium', 'width'); ?>,
getVar("gallery/transition/duration")): ?>
"transitionduration": getVar("gallery/transition/duration"); ?>,
"transition": "getVar("gallery/transition/effect"); ?>",
getVar("gallery/navarrows"))): ?>
"navarrows": getVar("gallery/navarrows"); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"navdir": "getVar("gallery/navdir"); ?>"
},
"fullscreen": {
"nav": "getVar("gallery/fullscreen/nav"); ?>",
getVar("gallery/fullscreen/loop")): ?>
"loop": getVar("gallery/fullscreen/loop"); ?>,
"navdir": "getVar("gallery/fullscreen/navdir"); ?>",
getVar("gallery/transition/navarrows")): ?>
"navarrows": getVar("gallery/fullscreen/navarrows"); ?>,
"navtype": "getVar("gallery/fullscreen/navtype"); ?>",
getVar("gallery/fullscreen/arrows")): ?>
"arrows": getVar("gallery/fullscreen/arrows"); ?>,
getVar("gallery/fullscreen/caption")): ?>
"showCaption": getVar("gallery/fullscreen/caption"); ?>,
getVar("gallery/fullscreen/transition/duration")): ?>
"transitionduration": getVar("gallery/fullscreen/transition/duration"); ?>,
"transition": "getVar("gallery/fullscreen/transition/effect"); ?>"
},
"breakpoints": getBreakpoints(); ?>
}
}
}
this is php class appcodeIbnabCloudZoomyBlockProductView
namespace IbnabCloudZoomyBlockProductView;
use MagentoFrameworkDataCollection;
use MagentoFrameworkJsonEncoderInterface;
use MagentoCatalogHelperImage;
use MagentoFrameworkAppConfigScopeConfigInterface;
class Gallery extends MagentoCatalogBlockProductViewAbstractView
{
/**
* @var MagentoFrameworkConfigView
*/
protected $configView;
/**
* @var MagentoFrameworkJsonEncoderInterface
*/
protected $jsonEncoder;
protected $_template = 'Ibnab_CloudZoomy::product/view/gallery.phtml';
/**
* @var IbnabCloudZoomyHelperData
*/
protected $dataHelper;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoFrameworkStdlibArrayUtils $arrayUtils
* @param EncoderInterface $jsonEncoder
* @param array $data
*/
public function __construct(
IbnabCloudZoomyHelperData $dataHelper,
MagentoCatalogBlockProductContext $context,
MagentoFrameworkStdlibArrayUtils $arrayUtils,
EncoderInterface $jsonEncoder,
array $data =
) {
$this->jsonEncoder = $jsonEncoder;
$this->dataHelper = $dataHelper;
parent::__construct($context, $arrayUtils, $data);
}
/**
* Retrieve collection of gallery images
*
* @return Collection
*/
public function getGalleryImages()
{
$product = $this->getProduct();
$images = $product->getMediaGalleryImages();
if ($images instanceof MagentoFrameworkDataCollection) {
foreach ($images as $image) {
/* @var MagentoFrameworkDataObject $image */
$image->setData(
'small_image_url',
$this->_imageHelper->init($product, 'product_page_image_small')
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'medium_image_url',
$this->_imageHelper->init($product, 'product_page_image_medium')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'large_image_url',
$this->_imageHelper->init($product, 'product_page_image_large')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
}
}
return $images;
}
/**
* Return magnifier options
*
* @return string
*/
public function getMagnifier()
{
return $this->jsonEncoder->encode($this->getVar('magnifier'));
}
/**
* Return breakpoints options
*
* @return string
*/
public function getBreakpoints()
{
return $this->jsonEncoder->encode($this->getVar('breakpoints'));
}
/**
* Retrieve product images in JSON format
*
* @return string
*/
public function getGalleryImagesJson()
{
$imagesItems = ;
foreach ($this->getGalleryImages() as $image) {
$imagesItems = [
'thumb' => $image->getData('small_image_url'),
'img' => $image->getData('medium_image_url'),
'full' => $image->getData('large_image_url'),
'caption' => $image->getLabel(),
'position' => $image->getPosition(),
'isMain' => $this->isMainImage($image),
];
}
if (empty($imagesItems)) {
$imagesItems = [
'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'caption' => '',
'position' => '0',
'isMain' => true,
];
}
return json_encode($imagesItems);
}
/**
* Retrieve gallery url
*
* @param null|MagentoFrameworkDataObject $image
* @return string
*/
public function getGalleryUrl($image = null)
{
$params = ['id' => $this->getProduct()->getId()];
if ($image) {
$params['image'] = $image->getValueId();
}
return $this->getUrl('catalog/product/gallery', $params);
}
/**
* Is product main image
*
* @param MagentoFrameworkDataObject $image
* @return bool
*/
public function isMainImage($image)
{
$product = $this->getProduct();
return $product->getImage() == $image->getFile();
}
/**
* @param string $imageId
* @param string $attributeName
* @param string $default
* @return string
*/
public function getImageAttribute($imageId, $attributeName, $default = null)
{
$attributes =
$this->getConfigView()->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
return isset($attributes[$attributeName]) ? $attributes[$attributeName] : $default;
}
/**
* Retrieve config view
*
* @return MagentoFrameworkConfigView
*/
private function getConfigView()
{
if (!$this->configView) {
$this->configView = $this->_viewConfig->getViewConfig();
}
return $this->configView;
}
public function getConfigValue($path){
return $this->dataHelper->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
}
}
magento2 extensions
New contributor
add a comment |
this is app/code/Ibnab/CloudZoomy/etc/frontend/di.xml
----------
this is phtml app/code/Ibnab/CloudZoomy/view/frontend/templates/product/view/gallery.phtml
getConfigValue('ibnab_cloud_config/general/enabledisable');
$jsonGallery = $block->getGalleryImagesJson();
$arrayJsonGallery = json_decode($jsonGallery, true);
$useragent=$_SERVER['HTTP_USER_AGENT'];
if($typeGallery == 1 && !preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4))):
?>
" class = 'cloud-zoom' id='zoom1'rel="" >
" title="" />
' class='cloud-zoom-gallery' title='Thumbnail '
rel="useZoom: 'zoom1', smallImage: '' ">
" alt = ""/>
<script>
require([
'jquery',
'ibnabzoom',
'mage/apply/main',
'galleryList'
], function ($, ibnabzoom, mage, gallery) {
});
</script>
getViewFileUrl('images/loader-1.gif'); ?>"
alt="">
var config = {
"width": getImageAttribute('product_page_image_medium', 'width'); ?>,
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"height": getImageAttribute('product_page_image_medium', 'height'); ?>
},
thumbBarHeight = 0,
loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];
if (config.navtype === 'horizontal') {
thumbBarHeight = config.thumbheight;
}
loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
{
"[data-gallery-role=gallery-placeholder]": {
"mage/gallery/gallery": {
"mixins":["magnifier/magnify"],
"magnifierOpts": getMagnifier(); ?>,
"data": getGalleryImagesJson(); ?>,
"options": {
"nav": "getVar("gallery/nav"); ?>",
getVar("gallery/loop"))): ?>
"loop": getVar("gallery/loop"); ?>,
getVar("gallery/keyboard"))): ?>
"keyboard": getVar("gallery/keyboard"); ?>,
getVar("gallery/arrows"))): ?>
"arrows": getVar("gallery/arrows"); ?>,
getVar("gallery/allowfullscreen"))): ?>
"allowfullscreen": getVar("gallery/allowfullscreen"); ?>,
getVar("gallery/caption"))): ?>
"showCaption": getVar("gallery/caption"); ?>,
"width": "getImageAttribute('product_page_image_medium', 'width'); ?>",
"thumbwidth": "getImageAttribute('product_page_image_small', 'width'); ?>",
getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
getImageAttribute('product_page_image_medium', 'height') || $block->getImageAttribute('product_page_image_medium', 'width')): ?>
"height": getImageAttribute('product_page_image_medium', 'height')
?: $block->getImageAttribute('product_page_image_medium', 'width'); ?>,
getVar("gallery/transition/duration")): ?>
"transitionduration": getVar("gallery/transition/duration"); ?>,
"transition": "getVar("gallery/transition/effect"); ?>",
getVar("gallery/navarrows"))): ?>
"navarrows": getVar("gallery/navarrows"); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"navdir": "getVar("gallery/navdir"); ?>"
},
"fullscreen": {
"nav": "getVar("gallery/fullscreen/nav"); ?>",
getVar("gallery/fullscreen/loop")): ?>
"loop": getVar("gallery/fullscreen/loop"); ?>,
"navdir": "getVar("gallery/fullscreen/navdir"); ?>",
getVar("gallery/transition/navarrows")): ?>
"navarrows": getVar("gallery/fullscreen/navarrows"); ?>,
"navtype": "getVar("gallery/fullscreen/navtype"); ?>",
getVar("gallery/fullscreen/arrows")): ?>
"arrows": getVar("gallery/fullscreen/arrows"); ?>,
getVar("gallery/fullscreen/caption")): ?>
"showCaption": getVar("gallery/fullscreen/caption"); ?>,
getVar("gallery/fullscreen/transition/duration")): ?>
"transitionduration": getVar("gallery/fullscreen/transition/duration"); ?>,
"transition": "getVar("gallery/fullscreen/transition/effect"); ?>"
},
"breakpoints": getBreakpoints(); ?>
}
}
}
this is php class appcodeIbnabCloudZoomyBlockProductView
namespace IbnabCloudZoomyBlockProductView;
use MagentoFrameworkDataCollection;
use MagentoFrameworkJsonEncoderInterface;
use MagentoCatalogHelperImage;
use MagentoFrameworkAppConfigScopeConfigInterface;
class Gallery extends MagentoCatalogBlockProductViewAbstractView
{
/**
* @var MagentoFrameworkConfigView
*/
protected $configView;
/**
* @var MagentoFrameworkJsonEncoderInterface
*/
protected $jsonEncoder;
protected $_template = 'Ibnab_CloudZoomy::product/view/gallery.phtml';
/**
* @var IbnabCloudZoomyHelperData
*/
protected $dataHelper;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoFrameworkStdlibArrayUtils $arrayUtils
* @param EncoderInterface $jsonEncoder
* @param array $data
*/
public function __construct(
IbnabCloudZoomyHelperData $dataHelper,
MagentoCatalogBlockProductContext $context,
MagentoFrameworkStdlibArrayUtils $arrayUtils,
EncoderInterface $jsonEncoder,
array $data =
) {
$this->jsonEncoder = $jsonEncoder;
$this->dataHelper = $dataHelper;
parent::__construct($context, $arrayUtils, $data);
}
/**
* Retrieve collection of gallery images
*
* @return Collection
*/
public function getGalleryImages()
{
$product = $this->getProduct();
$images = $product->getMediaGalleryImages();
if ($images instanceof MagentoFrameworkDataCollection) {
foreach ($images as $image) {
/* @var MagentoFrameworkDataObject $image */
$image->setData(
'small_image_url',
$this->_imageHelper->init($product, 'product_page_image_small')
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'medium_image_url',
$this->_imageHelper->init($product, 'product_page_image_medium')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'large_image_url',
$this->_imageHelper->init($product, 'product_page_image_large')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
}
}
return $images;
}
/**
* Return magnifier options
*
* @return string
*/
public function getMagnifier()
{
return $this->jsonEncoder->encode($this->getVar('magnifier'));
}
/**
* Return breakpoints options
*
* @return string
*/
public function getBreakpoints()
{
return $this->jsonEncoder->encode($this->getVar('breakpoints'));
}
/**
* Retrieve product images in JSON format
*
* @return string
*/
public function getGalleryImagesJson()
{
$imagesItems = ;
foreach ($this->getGalleryImages() as $image) {
$imagesItems = [
'thumb' => $image->getData('small_image_url'),
'img' => $image->getData('medium_image_url'),
'full' => $image->getData('large_image_url'),
'caption' => $image->getLabel(),
'position' => $image->getPosition(),
'isMain' => $this->isMainImage($image),
];
}
if (empty($imagesItems)) {
$imagesItems = [
'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'caption' => '',
'position' => '0',
'isMain' => true,
];
}
return json_encode($imagesItems);
}
/**
* Retrieve gallery url
*
* @param null|MagentoFrameworkDataObject $image
* @return string
*/
public function getGalleryUrl($image = null)
{
$params = ['id' => $this->getProduct()->getId()];
if ($image) {
$params['image'] = $image->getValueId();
}
return $this->getUrl('catalog/product/gallery', $params);
}
/**
* Is product main image
*
* @param MagentoFrameworkDataObject $image
* @return bool
*/
public function isMainImage($image)
{
$product = $this->getProduct();
return $product->getImage() == $image->getFile();
}
/**
* @param string $imageId
* @param string $attributeName
* @param string $default
* @return string
*/
public function getImageAttribute($imageId, $attributeName, $default = null)
{
$attributes =
$this->getConfigView()->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
return isset($attributes[$attributeName]) ? $attributes[$attributeName] : $default;
}
/**
* Retrieve config view
*
* @return MagentoFrameworkConfigView
*/
private function getConfigView()
{
if (!$this->configView) {
$this->configView = $this->_viewConfig->getViewConfig();
}
return $this->configView;
}
public function getConfigValue($path){
return $this->dataHelper->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
}
}
magento2 extensions
New contributor
add a comment |
this is app/code/Ibnab/CloudZoomy/etc/frontend/di.xml
----------
this is phtml app/code/Ibnab/CloudZoomy/view/frontend/templates/product/view/gallery.phtml
getConfigValue('ibnab_cloud_config/general/enabledisable');
$jsonGallery = $block->getGalleryImagesJson();
$arrayJsonGallery = json_decode($jsonGallery, true);
$useragent=$_SERVER['HTTP_USER_AGENT'];
if($typeGallery == 1 && !preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4))):
?>
" class = 'cloud-zoom' id='zoom1'rel="" >
" title="" />
' class='cloud-zoom-gallery' title='Thumbnail '
rel="useZoom: 'zoom1', smallImage: '' ">
" alt = ""/>
<script>
require([
'jquery',
'ibnabzoom',
'mage/apply/main',
'galleryList'
], function ($, ibnabzoom, mage, gallery) {
});
</script>
getViewFileUrl('images/loader-1.gif'); ?>"
alt="">
var config = {
"width": getImageAttribute('product_page_image_medium', 'width'); ?>,
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"height": getImageAttribute('product_page_image_medium', 'height'); ?>
},
thumbBarHeight = 0,
loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];
if (config.navtype === 'horizontal') {
thumbBarHeight = config.thumbheight;
}
loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
{
"[data-gallery-role=gallery-placeholder]": {
"mage/gallery/gallery": {
"mixins":["magnifier/magnify"],
"magnifierOpts": getMagnifier(); ?>,
"data": getGalleryImagesJson(); ?>,
"options": {
"nav": "getVar("gallery/nav"); ?>",
getVar("gallery/loop"))): ?>
"loop": getVar("gallery/loop"); ?>,
getVar("gallery/keyboard"))): ?>
"keyboard": getVar("gallery/keyboard"); ?>,
getVar("gallery/arrows"))): ?>
"arrows": getVar("gallery/arrows"); ?>,
getVar("gallery/allowfullscreen"))): ?>
"allowfullscreen": getVar("gallery/allowfullscreen"); ?>,
getVar("gallery/caption"))): ?>
"showCaption": getVar("gallery/caption"); ?>,
"width": "getImageAttribute('product_page_image_medium', 'width'); ?>",
"thumbwidth": "getImageAttribute('product_page_image_small', 'width'); ?>",
getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
getImageAttribute('product_page_image_medium', 'height') || $block->getImageAttribute('product_page_image_medium', 'width')): ?>
"height": getImageAttribute('product_page_image_medium', 'height')
?: $block->getImageAttribute('product_page_image_medium', 'width'); ?>,
getVar("gallery/transition/duration")): ?>
"transitionduration": getVar("gallery/transition/duration"); ?>,
"transition": "getVar("gallery/transition/effect"); ?>",
getVar("gallery/navarrows"))): ?>
"navarrows": getVar("gallery/navarrows"); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"navdir": "getVar("gallery/navdir"); ?>"
},
"fullscreen": {
"nav": "getVar("gallery/fullscreen/nav"); ?>",
getVar("gallery/fullscreen/loop")): ?>
"loop": getVar("gallery/fullscreen/loop"); ?>,
"navdir": "getVar("gallery/fullscreen/navdir"); ?>",
getVar("gallery/transition/navarrows")): ?>
"navarrows": getVar("gallery/fullscreen/navarrows"); ?>,
"navtype": "getVar("gallery/fullscreen/navtype"); ?>",
getVar("gallery/fullscreen/arrows")): ?>
"arrows": getVar("gallery/fullscreen/arrows"); ?>,
getVar("gallery/fullscreen/caption")): ?>
"showCaption": getVar("gallery/fullscreen/caption"); ?>,
getVar("gallery/fullscreen/transition/duration")): ?>
"transitionduration": getVar("gallery/fullscreen/transition/duration"); ?>,
"transition": "getVar("gallery/fullscreen/transition/effect"); ?>"
},
"breakpoints": getBreakpoints(); ?>
}
}
}
this is php class appcodeIbnabCloudZoomyBlockProductView
namespace IbnabCloudZoomyBlockProductView;
use MagentoFrameworkDataCollection;
use MagentoFrameworkJsonEncoderInterface;
use MagentoCatalogHelperImage;
use MagentoFrameworkAppConfigScopeConfigInterface;
class Gallery extends MagentoCatalogBlockProductViewAbstractView
{
/**
* @var MagentoFrameworkConfigView
*/
protected $configView;
/**
* @var MagentoFrameworkJsonEncoderInterface
*/
protected $jsonEncoder;
protected $_template = 'Ibnab_CloudZoomy::product/view/gallery.phtml';
/**
* @var IbnabCloudZoomyHelperData
*/
protected $dataHelper;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoFrameworkStdlibArrayUtils $arrayUtils
* @param EncoderInterface $jsonEncoder
* @param array $data
*/
public function __construct(
IbnabCloudZoomyHelperData $dataHelper,
MagentoCatalogBlockProductContext $context,
MagentoFrameworkStdlibArrayUtils $arrayUtils,
EncoderInterface $jsonEncoder,
array $data =
) {
$this->jsonEncoder = $jsonEncoder;
$this->dataHelper = $dataHelper;
parent::__construct($context, $arrayUtils, $data);
}
/**
* Retrieve collection of gallery images
*
* @return Collection
*/
public function getGalleryImages()
{
$product = $this->getProduct();
$images = $product->getMediaGalleryImages();
if ($images instanceof MagentoFrameworkDataCollection) {
foreach ($images as $image) {
/* @var MagentoFrameworkDataObject $image */
$image->setData(
'small_image_url',
$this->_imageHelper->init($product, 'product_page_image_small')
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'medium_image_url',
$this->_imageHelper->init($product, 'product_page_image_medium')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'large_image_url',
$this->_imageHelper->init($product, 'product_page_image_large')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
}
}
return $images;
}
/**
* Return magnifier options
*
* @return string
*/
public function getMagnifier()
{
return $this->jsonEncoder->encode($this->getVar('magnifier'));
}
/**
* Return breakpoints options
*
* @return string
*/
public function getBreakpoints()
{
return $this->jsonEncoder->encode($this->getVar('breakpoints'));
}
/**
* Retrieve product images in JSON format
*
* @return string
*/
public function getGalleryImagesJson()
{
$imagesItems = ;
foreach ($this->getGalleryImages() as $image) {
$imagesItems = [
'thumb' => $image->getData('small_image_url'),
'img' => $image->getData('medium_image_url'),
'full' => $image->getData('large_image_url'),
'caption' => $image->getLabel(),
'position' => $image->getPosition(),
'isMain' => $this->isMainImage($image),
];
}
if (empty($imagesItems)) {
$imagesItems = [
'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'caption' => '',
'position' => '0',
'isMain' => true,
];
}
return json_encode($imagesItems);
}
/**
* Retrieve gallery url
*
* @param null|MagentoFrameworkDataObject $image
* @return string
*/
public function getGalleryUrl($image = null)
{
$params = ['id' => $this->getProduct()->getId()];
if ($image) {
$params['image'] = $image->getValueId();
}
return $this->getUrl('catalog/product/gallery', $params);
}
/**
* Is product main image
*
* @param MagentoFrameworkDataObject $image
* @return bool
*/
public function isMainImage($image)
{
$product = $this->getProduct();
return $product->getImage() == $image->getFile();
}
/**
* @param string $imageId
* @param string $attributeName
* @param string $default
* @return string
*/
public function getImageAttribute($imageId, $attributeName, $default = null)
{
$attributes =
$this->getConfigView()->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
return isset($attributes[$attributeName]) ? $attributes[$attributeName] : $default;
}
/**
* Retrieve config view
*
* @return MagentoFrameworkConfigView
*/
private function getConfigView()
{
if (!$this->configView) {
$this->configView = $this->_viewConfig->getViewConfig();
}
return $this->configView;
}
public function getConfigValue($path){
return $this->dataHelper->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
}
}
magento2 extensions
New contributor
this is app/code/Ibnab/CloudZoomy/etc/frontend/di.xml
----------
this is phtml app/code/Ibnab/CloudZoomy/view/frontend/templates/product/view/gallery.phtml
getConfigValue('ibnab_cloud_config/general/enabledisable');
$jsonGallery = $block->getGalleryImagesJson();
$arrayJsonGallery = json_decode($jsonGallery, true);
$useragent=$_SERVER['HTTP_USER_AGENT'];
if($typeGallery == 1 && !preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4))):
?>
" class = 'cloud-zoom' id='zoom1'rel="" >
" title="" />
' class='cloud-zoom-gallery' title='Thumbnail '
rel="useZoom: 'zoom1', smallImage: '' ">
" alt = ""/>
<script>
require([
'jquery',
'ibnabzoom',
'mage/apply/main',
'galleryList'
], function ($, ibnabzoom, mage, gallery) {
});
</script>
getViewFileUrl('images/loader-1.gif'); ?>"
alt="">
var config = {
"width": getImageAttribute('product_page_image_medium', 'width'); ?>,
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"height": getImageAttribute('product_page_image_medium', 'height'); ?>
},
thumbBarHeight = 0,
loader = document.querySelectorAll('[data-gallery-role="gallery-placeholder"] [data-role="loader"]')[0];
if (config.navtype === 'horizontal') {
thumbBarHeight = config.thumbheight;
}
loader.style.paddingBottom = ( config.height / config.width * 100) + "%";
{
"[data-gallery-role=gallery-placeholder]": {
"mage/gallery/gallery": {
"mixins":["magnifier/magnify"],
"magnifierOpts": getMagnifier(); ?>,
"data": getGalleryImagesJson(); ?>,
"options": {
"nav": "getVar("gallery/nav"); ?>",
getVar("gallery/loop"))): ?>
"loop": getVar("gallery/loop"); ?>,
getVar("gallery/keyboard"))): ?>
"keyboard": getVar("gallery/keyboard"); ?>,
getVar("gallery/arrows"))): ?>
"arrows": getVar("gallery/arrows"); ?>,
getVar("gallery/allowfullscreen"))): ?>
"allowfullscreen": getVar("gallery/allowfullscreen"); ?>,
getVar("gallery/caption"))): ?>
"showCaption": getVar("gallery/caption"); ?>,
"width": "getImageAttribute('product_page_image_medium', 'width'); ?>",
"thumbwidth": "getImageAttribute('product_page_image_small', 'width'); ?>",
getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
"thumbheight": getImageAttribute('product_page_image_small', 'height')
?: $block->getImageAttribute('product_page_image_small', 'width'); ?>,
getImageAttribute('product_page_image_medium', 'height') || $block->getImageAttribute('product_page_image_medium', 'width')): ?>
"height": getImageAttribute('product_page_image_medium', 'height')
?: $block->getImageAttribute('product_page_image_medium', 'width'); ?>,
getVar("gallery/transition/duration")): ?>
"transitionduration": getVar("gallery/transition/duration"); ?>,
"transition": "getVar("gallery/transition/effect"); ?>",
getVar("gallery/navarrows"))): ?>
"navarrows": getVar("gallery/navarrows"); ?>,
"navtype": "getVar("gallery/navtype"); ?>",
"navdir": "getVar("gallery/navdir"); ?>"
},
"fullscreen": {
"nav": "getVar("gallery/fullscreen/nav"); ?>",
getVar("gallery/fullscreen/loop")): ?>
"loop": getVar("gallery/fullscreen/loop"); ?>,
"navdir": "getVar("gallery/fullscreen/navdir"); ?>",
getVar("gallery/transition/navarrows")): ?>
"navarrows": getVar("gallery/fullscreen/navarrows"); ?>,
"navtype": "getVar("gallery/fullscreen/navtype"); ?>",
getVar("gallery/fullscreen/arrows")): ?>
"arrows": getVar("gallery/fullscreen/arrows"); ?>,
getVar("gallery/fullscreen/caption")): ?>
"showCaption": getVar("gallery/fullscreen/caption"); ?>,
getVar("gallery/fullscreen/transition/duration")): ?>
"transitionduration": getVar("gallery/fullscreen/transition/duration"); ?>,
"transition": "getVar("gallery/fullscreen/transition/effect"); ?>"
},
"breakpoints": getBreakpoints(); ?>
}
}
}
this is php class appcodeIbnabCloudZoomyBlockProductView
namespace IbnabCloudZoomyBlockProductView;
use MagentoFrameworkDataCollection;
use MagentoFrameworkJsonEncoderInterface;
use MagentoCatalogHelperImage;
use MagentoFrameworkAppConfigScopeConfigInterface;
class Gallery extends MagentoCatalogBlockProductViewAbstractView
{
/**
* @var MagentoFrameworkConfigView
*/
protected $configView;
/**
* @var MagentoFrameworkJsonEncoderInterface
*/
protected $jsonEncoder;
protected $_template = 'Ibnab_CloudZoomy::product/view/gallery.phtml';
/**
* @var IbnabCloudZoomyHelperData
*/
protected $dataHelper;
/**
* @param MagentoCatalogBlockProductContext $context
* @param MagentoFrameworkStdlibArrayUtils $arrayUtils
* @param EncoderInterface $jsonEncoder
* @param array $data
*/
public function __construct(
IbnabCloudZoomyHelperData $dataHelper,
MagentoCatalogBlockProductContext $context,
MagentoFrameworkStdlibArrayUtils $arrayUtils,
EncoderInterface $jsonEncoder,
array $data =
) {
$this->jsonEncoder = $jsonEncoder;
$this->dataHelper = $dataHelper;
parent::__construct($context, $arrayUtils, $data);
}
/**
* Retrieve collection of gallery images
*
* @return Collection
*/
public function getGalleryImages()
{
$product = $this->getProduct();
$images = $product->getMediaGalleryImages();
if ($images instanceof MagentoFrameworkDataCollection) {
foreach ($images as $image) {
/* @var MagentoFrameworkDataObject $image */
$image->setData(
'small_image_url',
$this->_imageHelper->init($product, 'product_page_image_small')
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'medium_image_url',
$this->_imageHelper->init($product, 'product_page_image_medium')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
$image->setData(
'large_image_url',
$this->_imageHelper->init($product, 'product_page_image_large')
->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)
->setImageFile($image->getFile())
->getUrl()
);
}
}
return $images;
}
/**
* Return magnifier options
*
* @return string
*/
public function getMagnifier()
{
return $this->jsonEncoder->encode($this->getVar('magnifier'));
}
/**
* Return breakpoints options
*
* @return string
*/
public function getBreakpoints()
{
return $this->jsonEncoder->encode($this->getVar('breakpoints'));
}
/**
* Retrieve product images in JSON format
*
* @return string
*/
public function getGalleryImagesJson()
{
$imagesItems = ;
foreach ($this->getGalleryImages() as $image) {
$imagesItems = [
'thumb' => $image->getData('small_image_url'),
'img' => $image->getData('medium_image_url'),
'full' => $image->getData('large_image_url'),
'caption' => $image->getLabel(),
'position' => $image->getPosition(),
'isMain' => $this->isMainImage($image),
];
}
if (empty($imagesItems)) {
$imagesItems = [
'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
'caption' => '',
'position' => '0',
'isMain' => true,
];
}
return json_encode($imagesItems);
}
/**
* Retrieve gallery url
*
* @param null|MagentoFrameworkDataObject $image
* @return string
*/
public function getGalleryUrl($image = null)
{
$params = ['id' => $this->getProduct()->getId()];
if ($image) {
$params['image'] = $image->getValueId();
}
return $this->getUrl('catalog/product/gallery', $params);
}
/**
* Is product main image
*
* @param MagentoFrameworkDataObject $image
* @return bool
*/
public function isMainImage($image)
{
$product = $this->getProduct();
return $product->getImage() == $image->getFile();
}
/**
* @param string $imageId
* @param string $attributeName
* @param string $default
* @return string
*/
public function getImageAttribute($imageId, $attributeName, $default = null)
{
$attributes =
$this->getConfigView()->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
return isset($attributes[$attributeName]) ? $attributes[$attributeName] : $default;
}
/**
* Retrieve config view
*
* @return MagentoFrameworkConfigView
*/
private function getConfigView()
{
if (!$this->configView) {
$this->configView = $this->_viewConfig->getViewConfig();
}
return $this->configView;
}
public function getConfigValue($path){
return $this->dataHelper->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
}
}
magento2 extensions
magento2 extensions
New contributor
New contributor
New contributor
asked 2 mins ago
raginiragini
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
ragini is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258313%2fmagento-2-free-quick-cloud-zoom-extension-di-xml-not-getting-override%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
ragini is a new contributor. Be nice, and check out our Code of Conduct.
ragini is a new contributor. Be nice, and check out our Code of Conduct.
ragini is a new contributor. Be nice, and check out our Code of Conduct.
ragini is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258313%2fmagento-2-free-quick-cloud-zoom-extension-di-xml-not-getting-override%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown