2014-07-17 38 views
0

我使用https://github.com/josegonzalez/cakephp-uploadCakePHP的上傳插件 - 不創建縮略圖

的問題是上傳插件,而主圖像上傳細,它不創建縮略圖。

這裏是我的模型代碼

public $actsAs = array(
    'Upload.Upload' => array(
     'image' => array(
      'thumbnailSizes' => array(
       'featured' => '720x400', 
       'xsmall' => '98x98', 
       'small' => '152x110', 
       'medium' => '400x222', 
       'large' => '225x145', 
       'medium_home' => '232x128', 
       'xlarge' => '720x632', 
       'editorial' => '199x300', 
       'medium_editorial' => '180x249', 
       'small_editorial' => '152x211', 
       'xsmall_editorial' => '98x136' 
      ), 
      'path' => '{ROOT}webroot{DS}uploads{DS}{model}{DS}{field}{DS}' 
     ) 
    ) 
); 

我應該改變任何想法?

回答

1

添加'thumbnails' => true'thumbnailMethod' => 'php'您陣列中的代碼如下:

public $actsAs = array(
    'Upload.Upload' => array(
     'image' => array(
      'thumbnails' => true, 
      'thumbnailMethod' => 'php', 
      'thumbnailSizes' => array(
       'featured' => '720x400', 
       'xsmall' => '98x98', 
       'small' => '152x110', 
       'medium' => '400x222', 
       'large' => '225x145', 
       'medium_home' => '232x128', 
       'xlarge' => '720x632', 
       'editorial' => '199x300', 
       'medium_editorial' => '180x249', 
       'small_editorial' => '152x211', 
       'xsmall_editorial' => '98x136' 
      ), 
      'path' => '{ROOT}webroot{DS}uploads{DS}{model}{DS}{field}{DS}' 
     ) 
    ) 
); 

我用下面的代碼,它爲我工作得很好:

public $actsAs = array(
     'Upload.Upload' => array(
      'photo' => array(
       'fields' => array(
        'dir' => 'photo_dir' 
       ), 
       'deleteOnUpdate' => true, 
       'thumbnails' => true, 
       'thumbnailSizes' => array(
        '64x64' => '64x64' 
       ), 
       'thumbnailMethod' => 'php' 
      ) 
     ) 
    ); 
+0

NTkhan - 感謝您的建議,但它不起作用。 –

+1

我在我的答案中添加了代碼,並且工作正常。 – NTkhan

+1

gd已啓用或不在php.ini中,如果不啓用,則通過在php.ini中刪除';'從'; extension = php_gd.dll'啓用它,以防'thumbnailMethod'=>'php'' – NTkhan