增加每个类别的最大缩略图数量
Increase the maximum number of thumbnails per category
在分类管理AdminCategories里,我只能上传3张缩略图。
我想增加允许的最大数量。另外我还想增加最大文件大小。
我在AdminCategoriesController.php
中的方法renderForm()
中没有找到解决方案
在classes/helper/HelperForm.php
public function generate ()
{
(...)
case 'file':
$uploader = new HelperUploader();
$uploader->setId(isset($params['id'])?$params['id']:null);
$uploader->setName($params['name']);
$uploader->setUrl(isset($params['url'])?$params['url']:null);
$uploader->setMultiple(isset($params['multiple'])?$params['multiple']:false);
$uploader->setUseAjax(isset($params['ajax'])?$params['ajax']:false);
$uploader->setMaxFiles(isset($params['max_files'])?$params['max_files']:null);
if (isset($params['files']) && $params['files'])
$uploader->setFiles($params['files']);
elseif (isset($params['image']) && $params['image']) // Use for retrocompatibility
$uploader->setFiles(array(
0 => array(
'type' => HelperUploader::TYPE_IMAGE,
'image' => isset($params['image'])?$params['image']:null,
'size' => isset($params['size'])?$params['size']:null,
'delete_url' => isset($params['delete_url'])?$params['delete_url']:null
)));
if (isset($params['file']) && $params['file']) // Use for retrocompatibility
$uploader->setFiles(array(
0 => array(
'type' => HelperUploader::TYPE_FILE,
'size' => isset($params['size'])?$params['size']:null,
'delete_url' => isset($params['delete_url'])?$params['delete_url']:null,
'download_url' => isset($params['file'])?$params['file']:null
)));
if (isset($params['thumb']) && $params['thumb']) // Use for retrocompatibility
$uploader->setFiles(array(
0 => array(
'type' => HelperUploader::TYPE_IMAGE,
'image' => isset($params['thumb'])?'<img src="'.$params['thumb'].'" alt="'.(isset($params['title']) ? $params['title'] : '').'" title="'.(isset($params['title']) ? $params['title'] : '').'" />':null,
)));
$uploader->setTitle(isset($params['title'])?$params['title']:null);
$params['file'] = $uploader->render();
break;
(...)
}
您可以覆盖此 class 并使用来自 HelperUploader class 的 setMaxFiles 设置自定义值 class。
$uploader->setMaxFiles(isset($params['max_files'])?$params['max_files']:null);
在分类管理AdminCategories里,我只能上传3张缩略图。
我想增加允许的最大数量。另外我还想增加最大文件大小。
我在AdminCategoriesController.php
renderForm()
中没有找到解决方案
在classes/helper/HelperForm.php
public function generate ()
{
(...)
case 'file':
$uploader = new HelperUploader();
$uploader->setId(isset($params['id'])?$params['id']:null);
$uploader->setName($params['name']);
$uploader->setUrl(isset($params['url'])?$params['url']:null);
$uploader->setMultiple(isset($params['multiple'])?$params['multiple']:false);
$uploader->setUseAjax(isset($params['ajax'])?$params['ajax']:false);
$uploader->setMaxFiles(isset($params['max_files'])?$params['max_files']:null);
if (isset($params['files']) && $params['files'])
$uploader->setFiles($params['files']);
elseif (isset($params['image']) && $params['image']) // Use for retrocompatibility
$uploader->setFiles(array(
0 => array(
'type' => HelperUploader::TYPE_IMAGE,
'image' => isset($params['image'])?$params['image']:null,
'size' => isset($params['size'])?$params['size']:null,
'delete_url' => isset($params['delete_url'])?$params['delete_url']:null
)));
if (isset($params['file']) && $params['file']) // Use for retrocompatibility
$uploader->setFiles(array(
0 => array(
'type' => HelperUploader::TYPE_FILE,
'size' => isset($params['size'])?$params['size']:null,
'delete_url' => isset($params['delete_url'])?$params['delete_url']:null,
'download_url' => isset($params['file'])?$params['file']:null
)));
if (isset($params['thumb']) && $params['thumb']) // Use for retrocompatibility
$uploader->setFiles(array(
0 => array(
'type' => HelperUploader::TYPE_IMAGE,
'image' => isset($params['thumb'])?'<img src="'.$params['thumb'].'" alt="'.(isset($params['title']) ? $params['title'] : '').'" title="'.(isset($params['title']) ? $params['title'] : '').'" />':null,
)));
$uploader->setTitle(isset($params['title'])?$params['title']:null);
$params['file'] = $uploader->render();
break;
(...)
}
您可以覆盖此 class 并使用来自 HelperUploader class 的 setMaxFiles 设置自定义值 class。
$uploader->setMaxFiles(isset($params['max_files'])?$params['max_files']:null);