Installing and running LiipImagineBundle in symfony 2.1

天大地大妈咪最大 提交于 2019-12-06 04:30:41

问题


Here are the steps I followed:

  1. Added following in my composer.json:

    "require": {
         "imagine/Imagine": ">=0.2.8",
         "liip/imagine-bundle": "*@dev",
         ....
         }
    
  2. Ran following command at command line:

    composer update
    Installing imagine/imagine (v0.4.0)
    Installing liip/imagine-bundle (dev-master f7d5e4d)
    
  3. After composer update my directory structure inside vendor folder looks like as below:

  1. Then update vendor/composer/autoload_namespaces.php

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

    new Liip\ImagineBundle\LiipImagineBundle(),
    
  3. Routing:

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

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

    <img src="{{ asset('bundles/acmedemo/images/1.jpg') | imagine_filter('my_thumb') }}" />
    
  6. 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">

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


回答1:


When I replaced

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

with

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

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




回答2:


You might do: <img src="{{ (asset('bundles/acmedemo/images/1.jpg')) | imagine_filter('my_thumb') }}" /> because the filter filters the full image path and not only what asset() cointains, to mean you may also include the 'asset()'

Thanks



来源:https://stackoverflow.com/questions/14107488/installing-and-running-liipimaginebundle-in-symfony-2-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!