本文共 922 字,大约阅读时间需要 3 分钟。
1. magento图片的底层处理是在:/lib/Varien/Image/Adapter/Abstract.php 函数: public function backgroundColor($value = null) /** * Get/set keepBackgroundColor * * @param array $value * @return array */ public function backgroundColor($value = null) { if (null !== $value) { if ((!is_array($value)) || (3 !== count($value))) { return; } foreach ($value as $color) { if ((!is_integer($color)) || ($color < 0) || ($color > 255)) { return; } } } $this->_backgroundColor = $value; return $this->_backgroundColor; } 1.1注意: $this->_backgroundColor = $value;$value为rgb的颜色格式。 1.2 格式在线转换hex-->rgb http://www.yellowpipe.com/yis/tools/hex-to-rgb/color-converter.php /lib/Varien/Image/Adapter/abstract.php 1.3可以在这里直接更改$this->_backgroundColor,将所有的图片设置成一个颜色。 1.4 如果不同的图片对应的背景色不一样,那么需要在程序里面设置,如: <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(160, 190)->backgroundColor(248,248,248); ?> ,这里可以设置该图片的背景色,仅仅这一组。转载地址:http://pwcli.baihongyu.com/