2013-01-01 53 views
4

這裏運行LiipImagineBundle是我遵循的步驟:安裝和symfony的2.1

  1. 添加以下我composer.json:

    "require": { 
        "imagine/Imagine": ">=0.2.8", 
        "liip/imagine-bundle": "*@dev", 
        .... 
        } 
    
  2. 然在以下命令行命令:

    composer update 
    Installing imagine/imagine (v0.4.0) 
    Installing liip/imagine-bundle (dev-master f7d5e4d) 
    
  3. 作曲家更新後,供應商文件夾中的我的目錄結構看起來像下面:

enter image description here

  • 然後更新供應商/作曲家/ autoload_namespaces.php

    'Imagine' => $vendorDir .'/imagine/Imagine/lib/', 
    'Liip\\ImagineBundle'=>$vendorDir . '/liip/imagine-bundle/', 
    
  • 註冊束:

    new Liip\ImagineBundle\LiipImagineBundle(), 
    
  • 路由:

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

    # app/config/config.yml 
        liip_imagine: 
        filter_sets: 
        my_thumb: 
         quality: 75 
         filters: 
          thumbnail: { size: [120, 90], mode: outbound } 
    
  • 添加到小枝模板文件:

    <img src="{{ asset('bundles/acmedemo/images/1.jpg') | imagine_filter('my_thumb') }}" /> 
    
  • 打開本地主機/ symfony中/網絡/ app_dev.php /演示/你好/測試

  • There沒有縮略圖圖像生成。當查看源代碼時,我發現該行:

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

    我做了什麼我想念?有人能幫助我嗎?我使用的XAMPP 1.8在Windows XP上使用默認設置

    +0

    +1爲了您的安裝說明! – Mohebifar

    回答

    6

    當我更換

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

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

    我的縮略圖。我刪除了小枝的資產()幫手,它工作但不知道它是如何工作的。

    +0

    嗨,我也使用xampp,並且我已經完成了與您相同的所有步驟,但圖像仍未生成。您是否必須創建媒體/緩存目錄?沒有目錄創建,所以我創造了它們,仍然沒有圖像。它可能是一個權限問題? – Joe

    +1

    不,您不必手動創建媒體文件夾,除非您沒有寫入權限或創建目錄權限。如果你在windows上,這應該不是問題,但在linux上,需要寫入權限。請閱讀主題配置下的文檔https://github.com/liip/LiipImagineBundle – sonam

    +0

    我需要將liip/imaginebundle和想象/想像版本更改爲composer.json中的那些版本,並進行更新以使其工作,謝謝。 – Joe

    1

    你可以這樣做:<img src="{{ (asset('bundles/acmedemo/images/1.jpg')) | imagine_filter('my_thumb') }}" />因爲濾波器過濾完整的圖像路徑不僅什麼資產()cointains,表示你還可以包括「資產()」

    感謝