2015-01-15 131 views
2

我已經將blueimp jquery文件上傳了。我試圖做更多image_versions。 第一個和最後一個image_version確實有效。在我的情況下,'小'和'縮略圖'起作用,另一個不起作用。 在其他image_versions中,圖像將被上傳,但不會調整到正確的大小。blueimp jquery文件上傳器image_versions不起作用

這是我的代碼剪斷:

'image_versions' => array(
      // The empty image version key defines options for the original image: 
      '' => array(
       // Automatically rotate images based on EXIF meta data: 
       'auto_orient' => true 
      ), 
      'small' => array(
       'max_width' => 150, 
       'max_height' => 150 
      ), 

      'medium' => array(
       'max_width' => 200, 
       'max_height' => 200 
      ), 

      'large' => array(
       'max_width' => 400, 
       'max_height' => 400 
      ), 

      'xlarge' => array(
       'max_width' => 600, 
       'max_height' => 600 
      ), 

      'square' => array(
       'crop' => true, 
       'max_width' => 300, 
       'max_height' => 300 
      ), 

      'thumbnail' => array(
       'max_width' => 100, 
       'max_height' => 100 
      ) 
     ) 

回答

2

我只是碰到了這個確切同樣的問題。在代碼中仔細研究之後,我發現當它遍歷圖像版本時,它將生成的圖像對象保存在緩存中。所以在'small'被處理之後......一個緩存版本的結果圖像對象(150 x 150)被稱爲文件。

這樣源文件被簡單地複製爲介質,大,超大,和方形因爲代碼認爲圖像是150×150。然而縮略圖被處理,因爲它是比150×150

較小爲了解決這個問題,您可以將no_cache選項添加到您的圖像版本中 - 這會使代碼效率降低,但解決了您(和我)的問題。

所以你的代碼應該是這樣的:

'image_versions' => array(
    // The empty image version key defines options for the original image: 
    '' => array(
     // Automatically rotate images based on EXIF meta data: 
     'auto_orient' => true 
    ), 
    'small' => array(
     'max_width' => 150, 
     'max_height' => 150, 
     'no_cache' => true 
    ), 

    'medium' => array(
     'max_width' => 200, 
     'max_height' => 200, 
     'no_cache' => true 
    ), 

    'large' => array(
     'max_width' => 400, 
     'max_height' => 400, 
     'no_cache' => true 
    ), 

    'xlarge' => array(
     'max_width' => 600, 
     'max_height' => 600, 
     'no_cache' => true 
    ), 

    'square' => array(
     'crop' => true, 
     'max_width' => 300, 
     'max_height' => 300, 
     'no_cache' => true 
    ), 

    'thumbnail' => array(
     'max_width' => 100, 
     'max_height' => 100, 
     'no_cache' => true 
    ) 
) 
+0

'no_cache =>真' 的伎倆。這個問題浪費了整整一天。終於找到你的解決方案謝謝:)(y) – 2017-10-02 16:18:50