我正在显示任何尺寸的图像以适合 175x175 框架,因此它会在类别页面上失去其原始形状。
我想在调整大小后显示类别图像,以调整和显示类似产品图像的大小。
如何在 Magento 1.7.0.2 中执行此操作?
我正在显示任何尺寸的图像以适合 175x175 框架,因此它会在类别页面上失去其原始形状。
我想在调整大小后显示类别图像,以调整和显示类似产品图像的大小。
如何在 Magento 1.7.0.2 中执行此操作?
You will have to maually resize using Magento's image libs, herwes an example (http://blog.chapagain.com.np/magento-resize-image/):
// actual path of image
$imageUrl = Mage::getBaseDir('media').DS."myimage".DS.$post->getThumbnail();
// path of the resized image to be saved
// here, the resized image is saved in media/resized folder
$imageResized = Mage::getBaseDir('media').DS."myimage".DS."resized".DS.$post->getThumbnail();
// resize image only if the image file exists and the resized image file doesn't exist
// the image is resized proportionally with the width/height 135px
if (!file_exists($imageResized)&&file_exists($_imageUrl)) :
$imageObj = new Varien_Image($_imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(FALSE);
$imageObj->resize(135, 135);
$imageObj->save($imageResized);
endif;
$newImageUrl = Mage::getBaseUrl('media')."catalog/category/resized/".$imageName;
If you take a look at Varien_Image you will see there's a few different methods to help resize images. Unfortunately there's no helper to use as there is for product images, although it wouldn't be difficult to make a helper to do this.