如何在图库外获取产品图片标签?

时间:2011-04-01 09:48:09

标签: php image magento

我正在寻找一种获取图片标签的方法,而无需获取整个产品mediaGallery。 默认情况下,Magento就是这样做的:

<?php foreach ($this->getGalleryImages() as $_image): ?>
    <li>
        <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
    </li>
<?php endforeach; ?>

我想要做的是:

$_product->someimageattribute->getLabel()

1 个答案:

答案 0 :(得分:4)

以下是catalog/product/list.phtml的示例。

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />