在 symfony 2.1 中安装和运行 LiipImagineBundle [英] Installing and running LiipImagineBundle in symfony 2.1

查看:26
本文介绍了在 symfony 2.1 中安装和运行 LiipImagineBundle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我遵循的步骤:

  1. 在我的 composer.json 中添加以下内容:

  1. Added following in my composer.json:

"require": {
     "imagine/Imagine": ">=0.2.8",
     "liip/imagine-bundle": "*@dev",
     ....
     }

  • 在命令行运行以下命令:

  • Ran following command at command line:

    composer update
    Installing imagine/imagine (v0.4.0)
    Installing liip/imagine-bundle (dev-master f7d5e4d)
    

  • composer 更新后,vendor 文件夹中的目录结构如下所示:

  • After composer update my directory structure inside vendor folder looks like as below:

    1. 然后更新 vendor/composer/autoload_namespaces.php

    1. Then update vendor/composer/autoload_namespaces.php

     'Imagine'   => $vendorDir .'/imagine/Imagine/lib/',
     'Liip\\ImagineBundle'=>$vendorDir . '/liip/imagine-bundle/',
    

  • 注册捆绑包:

  • Registered bundle:

    new Liip\ImagineBundle\LiipImagineBundle(),
    

  • 路由:

  • Routing:

    # app/config/routing.yml
    _imagine:
    resource: .
    type:     imagine
    

  • config.yml

  • config.yml

      # app/config/config.yml
      liip_imagine:
      filter_sets:
         my_thumb:
            quality: 75
            filters:
               thumbnail: { size: [120, 90], mode: outbound }
    

  • 添加到树枝模板文件:

  • Added to twig template file:

    <img src="{{ asset('bundles/acmedemo/images/1.jpg') | imagine_filter('my_thumb') }}" />
    

  • 打开 localhost/symfony/web/app_dev.php/demo/hello/test

  • Open localhost/symfony/web/app_dev.php/demo/hello/test

    没有生成缩略图.查看源代码时,我发现了这一行:

    There was no thumbnail image generation. When viewing the source I found the line:

      <img src="/symfony/web/app_dev.php/media/cache/my_thumb/symfony/web/bundles/acmedemo/images/1.jpg">
    

    我错过了什么?有人可以帮我解决这个问题吗?我在默认设置下在 windows xp 上使用 xampp 1.8

    What I did I miss? Could somebody help me with this? I am using xampp 1.8 on windows xp with default settings

    推荐答案

    当我替换

     <img src="{{ asset('bundles/acmedemo/images/1.jpg') | imagine_filter('my_thumb') }}" />
    

     <img src="{{ 'bundles/acmedemo/images/1.jpg' | imagine_filter('my_thumb') }}" />
    

    我得到了缩略图.我删除了 twig 的 asset() 助手,它可以工作,但不知道它是如何工作的.

    I got the thumbnail. I removed the asset() helper of twig and it worked but dont know how it worked.

    这篇关于在 symfony 2.1 中安装和运行 LiipImagineBundle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆