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:

enter image description here

  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

有帮助吗?

解决方案

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.

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top