从皮肤文件夹Magento调整模板图像的大小

时间:2013-04-15 12:48:03

标签: magento

我想从\ skin \ frontend \\ default \ images位置显示已调整大小的图像。现在我使用简单         <img src="<?php echo $this->getSkinUrl('images/free_shipping.png')?>" alt="Free Shipping" /> 任何人都可以告诉我吗?

1 个答案:

答案 0 :(得分:0)

默认情况下,框magento仅允许您调整目录图像的大小,但您可以创建自己的功能来调整皮肤图像的大小。见http://magedev.com/2009/08/16/magento-image-manipulation/

$fileName = 'skin\frontend\default\default\images\media\col_left_callout.jpg';

$image = new Varien_Image($fileName);

// this function accepts integer, hexadecimal format is more convenient for me
$image->setImageBackgroundColor(0xFFFFFF);

$image->resize(250);


// this will generate proper headers for transformed image so don't use this method if you plan to display any other content
$image->display();

// Magento will attempt to create missing directories
$image->save('media/myimages/myTransformedImage.jpg');

另见