0

我正在使用自定义模板运行 magento。过去一周我一直在尝试将新产品小部件(无论是网格还是列表)的图像尺寸放大为 232 像素宽和 280 像素长。我已经成功地在 app/design/frontend/base/default/template/catalog/product/widget/new/content 找到了 new_grid.phtml 和 new_list.phtml 文件。我还将图像尺寸从我认为的 85 像素宽度和 85 像素长度更改为我想要的 232 像素宽度 x 280 像素长度。而不是放大图像的框架和图像本身,图像似乎被放大了,但框架在 85px 85px 处保持不变。因此,您只能在 85 x 85 像素的图像框架内看到图像的一小部分。我所说的小部件是您可以从 CMS 页面插入的新产品小部件。我正在运行 magento 社区版 1.7

这是 new_grid.phtml 的代码片段。任何帮助表示赞赏。谢谢

<div class="widget-products">
<?php $_columnCount = $this->getColumnCount(); ?>
    <?php $i=0; foreach ($_products->getItems() as $_product): ?>
    <?php if ($i++%$_columnCount==0): ?>
    <ul class="products-grid">
    <?php endif ?>
        <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(232,280) ?>" width="232" height="280" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a>
            <h3 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></h3>
            <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
            <?php echo $this->getPriceHtml($_product, true, '-widget-new-grid') ?>
            <div class="actions">
                <?php if ($_product->isSaleable()): ?>
                    <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 else: ?>
                    <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                <?php endif; ?>
                <ul class="add-to-links">
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
                    <?php endif; ?>
                    <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                        <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
                    <?php endif; ?>
                </ul>
            </div>
        </li>
    <?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
    </ul>
    <?php endif ?>
    <?php endforeach; ?>
4

3 回答 3

0

对于像我一样遇到这种情况的任何人...

通过更改 new.phtml 中的网格列表更正了我的问题:

<ul class="products-grid">

至:

<ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col">
于 2014-12-03T18:24:43.260 回答
0

这几乎可以肯定是一个 CSS 问题。

您似乎在这里正确调整了图像的大小:

<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(232,280) ?>

为确保您的新模板在布局中得到处理,您可以在系统/配置/开发人员选项卡中启用模板提示。

假设你做对了,它很可能会在 css 中重置为 85px。

来自widgets.css

.widget-new-products .products-grid .product-image,
.widget-new-products .products-list .product-image { width:85px; height:85px; }

我强烈建议您在您最喜欢的浏览器的检查工具中四处寻找,以确定究竟是什么规则覆盖了您的服务器端更改。

干杯

于 2012-10-08T16:52:31.190 回答
0

您可以使用 CSS For Image 将高度和宽度设置为您想要的值,无需更新模板,例如

<Your Image class/id>{
width:50%;
max-width:100%;
}

2)或者你可以使用js作为

jQuery("document").ready(function() {
    jQuery(".product-image img").attr({ width: "100%", height: "auto" });
});
于 2018-07-11T07:10:01.557 回答