我使用https://github.com/josegonzalez/cakephp-upload
中的上传插件问题是,虽然主图像上传得很好,但却没有创建缩略图。
这是我的型号代码
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}'
)
)
);
知道我应该改变什么?
答案 0 :(得分: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'
)
)
);