icybee / module-thumbnailer
按需创建缩略图。
Requires
- php: >=5.5.0
- ext-gd: *
- brickrouge/brickrouge: ^2.1.4
- icanboogie/event: ^1.4.0
- icanboogie/image: ^0.0.2
- icanboogie/module-installer: ^1.2.3
- icybee/module-registry: ^2.0.0
- olvlvl/filecache: dev-master
Requires (Dev)
- icanboogie/bind-activerecord: ^0.3.0
- icanboogie/icanboogie: ^2.4.0
- icybee/core: ^2.1.0
- icybee/module-cache: ^2.1.0
Suggests
- icybee/module-cache: Allows thumbnails cache management from Icybee's admin.
This package is auto-updated.
Last update: 2024-09-20 06:32:00 UTC
README
Thumbnailer模块(thumbnailer
)使用选项或配置的版本从图像和管理图像中创建缩略图。
该模块扩展了Image活动记录,添加了thumbnail()
方法和thumbnail
懒加载器,并提供了配置和管理其缓存的接口,该接口与"Cache"模块(缓存)的统一缓存系统集成。该模块还扩展了core对象,添加了thumbnail_versions
懒加载器。
<?php namespace ICanBoogie\Modules\Thumbnailer; $versions = $app->thumbnailer_versions; $versions['popover'] = [ 'width' => 420, 'height' => 340 ]; # or $versions['popover'] = 'w:420;h:340'; # or $versions['popover'] = '{"w":"420","h":"340"}'; # or $versions['popover'] = '420x340'; $thumbnail = new Thumbnail('/images/madonna.jpeg', 'popover'); echo $thumbnail; // <img src="/api/thumbnail/420x340/fill?s=%2Fimages%2Fmadonna.jpeg&v=popover" alt="" width="420" height="340" class="thumbnail thumbnail--popover" /> echo $thumbnail->url; // /api/thumbnail/420x340/fill?s=%2Fimages%2Fmadonna.jpeg&v=popover $thumbnail = new Thumbnail('/images/madonna.jpeg', '64x64.png'); echo $thumbnail; // <img src="/api/thumbnail/64x64/fill.png&s=%2Fimages%2Fmadonna.jpeg" alt="" width="64" height="64" class="thumbnail" /> echo $thumbnail->url; // /api/thumbnail/64x64/fill.png&s=%2Fimages%2Fmadonna.jpeg
事件钩子
ICanBoogie\Modules\System\Cache\CacheCollection::alter
将我们的缓存管理器添加到缓存集合中。
Icybee\ConfigBlock::alter_children
向模块配置块中添加一个thumbnails部分,该部分使用"thumbnails"配置定义缩略图版本。
Icybee\Operation\Module\ConfigOperation::properties:before
在保存配置之前预解析定义的缩略图版本。
原型方法
ICanBoogie\Core\get_thumbnail_versions
将thumbnail_versions
懒加载器添加到core对象。该加载器返回一个版本集合,该集合配置了注册表中保存的版本。第三方可以通过附加到ICanBoogie\Modules\Thumbnailer\Versions::alter
事件的钩子来修改此集合。
要求
该软件包需要PHP 5.5或更高版本。
安装
安装此软件包的推荐方法是使用Composer
$ composer require icybee/module-thumbnailer
克隆存储库
该软件包可在GitHub上找到,其存储库可以使用以下命令行克隆
$ git clone https://github.com/Icybee/module-thumbnailer.git thumbnailer
测试
测试套件使用make test
命令运行。自动安装了Composer以及运行套件所需的所有依赖项。可以使用make clean
命令清理软件包目录。
该软件包由Travis CI持续测试。
文档
该软件包作为Icybee CMS 文档的一部分进行文档记录。可以使用make doc
命令生成软件包及其依赖项的文档。文档使用ApiGen生成,并存储在docs
目录中。可以使用make clean
命令清理软件包目录。
许可证
此模块根据新BSD许可证授权 - 有关详细信息,请参阅LICENSE文件。