wearejust/image-optim-bundle

此包已被废弃,不再维护。没有推荐替代包。

包含二进制文件,可使用 Liip image 优化器

安装数: 1,046

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 3

分支: 0

公开问题: 0

类型:symfony-bundle

1.0 2017-09-20 08:32 UTC

This package is not auto-updated.

Last update: 2023-04-01 19:51:54 UTC


README

步骤 1: 下载包

打开命令行界面,进入您的项目目录,并执行以下命令以下载此包的最新稳定版本

$ composer require wearejust/image-optim-bundle "~1"

此命令要求您全局安装 Composer,请参阅 Composer 文档中的 安装章节

步骤 2: 启用包

然后,将包添加到项目 app/AppKernel.php 文件中注册的包列表中,以启用该包

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Wearejust\ImageOptimBundle\WearejustImageOptimBundle(),
        );

        // ...
    }

    // ...
}

步骤 3: 将额外配置添加到您的 config.yml 文件中

您可以使用自定义 yml 文件(如 Resources/config/theme.yml)覆盖我们提供的配置,如下所示

parameters:
  liip_imagine.jpegoptim.binary: '%kernel.root_dir%/../src/Wearejust/ImageOptimBundle/Resources/bin/jpegoptim'
  liip_imagine.optipng.binary: '%kernel.root_dir%/../src/Wearejust/ImageOptimBundle/Resources/bin/optipng-x64'
  liip_imagine.pngquant.binary: '%kernel.root_dir%/../src/Wearejust/ImageOptimBundle/Resources/bin/pngquant-x64'
  post_processes:
      jpegoptim: { strip_all: true, max: 70, progressive: true }
      optipng: { strip_all: true, level: 5 }

添加此配置后,您将在定义的过滤器预设中使用 post_processes 变量。以下是一个示例

liip_imagine :

    filter_sets :
        cache : ~

        home_hero_image:
            quality: 100
            filters:
                thumbnail:
                    crop: { start: [0, 0], size: [1100, 1100] }
                    position: center
            post_processors: '%post_processes%'