【问题标题】:Cakephp MeioUpload removeOrginalCakephp MeioUpload removeOrginal
【发布时间】:2012-05-24 16:49:53
【问题描述】:

removeOriginal 不适用于 MeioUpload !

我的帖子模型中有这段代码:

/model/post.php

 public $actsAs = array(
            'MeioUpload.MeioUpload' => array(
              'avatar' =>array(
                 'thumbnails' => true ,
                 'thumbsizes' => array('small'  => array('width'=>100, 'height'=>100)),
                 'thumbnailQuality' => 75, 
                 'thumbnailDir' => 'thumb',
                 'removeOriginal' => true 

               )
            )
        );

我只想上传大拇指,不需要源图。

(cakephp 2.1.2)

谢谢

【问题讨论】:

    标签: cakephp thumbnails cakephp-2.1 meio-upload


    【解决方案1】:

    此行为已弃用且不再受支持 (https://github.com/jrbasso/MeioUpload),但我遇到了同样的问题,无需迁移。

    对于与我同船的任何人,您可以按以下方式修复它:

    • 打开模型/行为/MeioUploadBehavior.php
    • 查找出现两次的代码块:

      // If the file is an image, try to make the thumbnails
      if ((count($options['thumbsizes']) > 0) && count($options['allowedExt']) > 0 && in_array($data[$model->alias][$fieldName]['type'], $this->_imageTypes)) {
          $this->_createThumbnails($model, $data, $fieldName, $saveAs, $ext, $options);
      }
      
    • 在第二次出现之后插入以下代码(确实已经出现在第一次出现的下方):

      if ($options['removeOriginal']) {
         $this->_removeOriginal($saveAs);
      }
      

    我在我的项目中这样做了,到目前为止似乎工作得很好!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-04
      • 2023-04-10
      相关资源
      最近更新 更多