CakePHP上传插件 - 不创建缩略图

时间:2014-07-17 10:10:02

标签: cakephp upload

我使用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}'
        )
    )
);

知道我应该改变什么?

1 个答案:

答案 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'
            )
        )
    );