【问题标题】:Magento - Resize images, keep aspect ratio, crop what exceeds the sizeMagento - 调整图像大小,保持纵横比,裁剪超出大小的内容
【发布时间】:2012-11-23 19:46:09
【问题描述】:

我想在 magento 中调整图像的大小,保持其纵横比,并使其填充另一个纵横比的矩形。

例子:

我的图像是 640x480

我的矩形是 100x50

我希望图像填充所有矩形并裁剪超出它的部分。

我知道 keepFrame(FALSE) - 它不会使图像填充矩形,而是使它适合内部并且不裁剪任何东西。

另外,如果您熟悉 Wordpress,我想要的是: *add_image_size('home',370,256,true);*

谢谢你:)

【问题讨论】:

标签: php image magento crop aspect-ratio


【解决方案1】:

看看@

由于 magento 已经改变了页面链接结构,请尝试http://web.archive.org/web/20140707042130/http://www.magentocommerce.com/boards/viewthread/47269/

Crop product thumbnail images to clean square

试试

<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(120,null); ?>" width="120" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />

【讨论】:

  • 虽然这个答案已经有一年多了,而且这个链接很有帮助,但是如果你在这个网站上发布答案的基本部分会更好,或者你的帖子有被删除的风险See the FAQ where it mentions answers that are 'barely more than a link'.你如果您愿意,仍然可以包含该链接,但仅作为“参考”。答案应该是独立的,不需要链接。
  • 这是 3 年前的答案。
猜你喜欢
  • 2014-03-02
  • 2013-10-05
  • 2013-06-26
  • 2012-04-15
  • 1970-01-01
  • 2012-05-01
相关资源
最近更新 更多