博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
magento----设置图片背景颜色(按数值设定后缺的部分用背景色填充)
阅读量:4199 次
发布时间:2019-05-26

本文共 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/

你可能感兴趣的文章
magento - 通过storeid,分类id,天数(几天内)得到产品
查看>>
一个很不错的bash脚本编写教程,至少没接触过BASH的也能看懂!
查看>>
Redis和Memcache对比及选择
查看>>
用谷歌账号登陆magento、
查看>>
php oauth 模块在linux下安装
查看>>
代替nginx的服务器 - The Tengine Web Server
查看>>
nginx 升级成 tengine 的代码
查看>>
magento rest api 调用
查看>>
magento rest api 调用!
查看>>
magento rest api get Token key and secret
查看>>
谷歌获取货币汇率代码
查看>>
安装nginx
查看>>
手动6 - 隐藏Nginx版本号
查看>>
手动7 - nginx 日志切割
查看>>
magento - 使用后台设置的时间用法
查看>>
Linux常用命令
查看>>
清除文件中的.svn文件
查看>>
手动11 -nginx 优化配置
查看>>
php加速器 - zendopcache
查看>>
手动12 - 安装php加速器 Zend OPcache
查看>>