【问题标题】:Resize template image from skin folder Magento从皮肤文件夹 Magento 调整模板图像的大小
【发布时间】:2013-04-15 12:48:03
【问题描述】:

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

【问题讨论】:

    标签: magento


    【解决方案1】:

    默认情况下,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');
    

    另见

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-23
      • 2012-12-02
      • 1970-01-01
      • 2011-10-27
      相关资源
      最近更新 更多