如何在magento中获得更大的图像?
问题描述:
我使用的是magento rwd主题,扩展名为 - 选定的产品小部件。如何在magento中获得更大的图像?
问题我无法增加图像的大小。 相关的代码是这样的:
<?php
$products = $this->getProductCollection();?>
<?php if ($products && $products->getSize()): ?>
<div class="block block-products selected-products">
<div class="block-title">
<strong><span><?php echo $this->getBlockName() ?></span></strong>
</div>
<div class="block-content">
<div class="products-block">
<?php foreach ($products->getItems() as $product): ?>
<?php /** @var $product Mage_Catalog_Model_Product */ ?>
<div class="item">
<a class="product-image"
href="<?php echo $product->getProductUrl() ?>"
title="<?php echo $this->stripTags($product->getName(), null, true) ?>">
<img
src="<?php echo $this->helper('catalog/image')->init($product, 'image')->resize(300,400) ?>"
alt="<?php echo $this->stripTags($product->getName(), null, true) ?>" />
</a>
<div class="product-details">
<p class="product-name">
<a href="<?php echo $product->getProductUrl() ?>"
title="<?php echo $this->stripTags($product->getName(), null, true) ?>)">
<?php echo $this->helper('catalog/output')->productAttribute($product, $product->getName(), 'name') ?>
</a>
</p>
<?php if ($product->getIsSalable()): ?>
<div class="product-price">
<?php echo $this->getPriceHtml($product, true) ?>
</div>
<button type="button"
title="<?php echo $this->__('Add to Cart') ?>"
class="button btn-cart"
onclick="setLocation('<?php echo $this->getAddToCartUrl($product) ?>')">
<span><span><?php echo $this->__('Add to Cart') ?></span></span>
</button>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
我已经调整大小设置为300x400,但我得到它 - 118x157
该网站的链接以供参考 - Change your Belief for Success
答
你有在调整大小之前将图像助手上的constrainOnly设置为true:
$this->helper('catalog/image')
->init($product, 'image')
->constrainOnly(true)
->resize(300,400);
来自该方法的PHPDoc:
Guarantee, that image picture will not be bigger, than it was.
Applicable before calling resize()
It is false by default
它不会变大。我添加了' - > constrainOnly(true)'。 – Joshi
然后尝试使用false,也许默认值会被覆盖,并且必须手动将其设置为false。 – Eydamos