现在我正在尝试遍历每个产品图片,并输出他们的全尺寸图片网址和图片大小。
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()); ?>
有什么想法吗?
答案 0 :(得分:0)
想出来!显然 - &gt; getOriginalWidth和 - &gt; getOriginalHeight不适用于其他主图像。
用它来解决它
<强> 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; ?>