现在我正试图循环浏览每个产品的图像,并输出它们的全尺寸图像url和图像大小。
PHP代码
<?php foreach ($this->getGalleryImages() as $_image): ?>
<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>
<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image')->getOriginalHeight(); ?>
<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image')->getOriginalWidth(); ?>
<?php endforeach; ?>
试图弄清楚为什么这会返回每个图像的主图像大小。
这个代码根本不起作用
<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->getOriginalWidth(); ?>
这也不是。。。
<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getOriginalWidth()); ?>
有什么想法吗?
想明白了!显然,->getOriginalWidth和->getOrientalHeight在其他主图像上不起作用。
用这个来解决
PHP
<?php foreach ($this->getGalleryImages() as $_image): ?>
<?php $fullImage = new Varien_Image($_image->getPath()); ?>
<?php echo $this->helper('catalog/image')->init($_product, 'image', $_image->getFile()); ?>'
<?php echo $fullImage->getOriginalWidth(); ?>
<?php echo $fullImage->getOriginalHeight(); ?>
<?php endforeach; ?>