biffbangpow/silverstripe-imagesize-validator
最新稳定版本:v1.0.0
Composer 安装命令:
composer require biffbangpow/silverstripe-imagesize-validator
包简介
Validates the dimensions of an image during upload
README 文档
README
This extends the standard upload validator and provides additional checks on the dimensions of an uploaded image.
The validator can be applied directly to an uploadfield:
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.Main', [ UploadField::create('Image')->setValidator(PixelSizeValidator::create()), ]); return $fields; }
Note: the validator should only be added to upload fields where the underlying class is an Image or subclass thereof. Adding the validator to an upload field where files may be uploaded will cause any non-images to be rejected.
By default the validator will reject an image which has a pixel dimension greater than 2000 in either axis. This can be overidden in yml config, eg:
--- Name: bbppixelsizevalidator --- BiffBangPow\Validators\PixelSizeValidator: max_width: 2500 max_height: 1200
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-08-31