2011-04-01 54 views
1

我正在寻找一种获取图像标签而无需获取整个产品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() 

回答

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) ?>" /> 
+0

嗨,谢谢你的回答。我们快到了:它在默认属性(image,small_image和缩略图)上工作正常,但我没有获得其他图像的标签:我改为产品名称。任何想法? – haltabush 2011-04-01 12:13:00

+0

@Jonathan如果我们想要访问自定义phtml文件中的图像标签,那么该怎么做? – Muk 2014-04-18 11:48:54

+0

@muk您需要提供比该评论更多的信息。请开始一个新的问题。 – 2014-04-27 06:04:11