femundfilou/kirby-image-snippet
最新稳定版本:2.0.0-beta.1
Composer 安装命令:
composer require femundfilou/kirby-image-snippet
包简介
Snippet + Helper Methods for handling images in Kirby
关键字:
README 文档
README
Snippet + Helper methods for handling images in Kirby 4+.
Installation
Install via composer
To use the snippet and helper methods you need to require this package via composer.
composer require femundfilou/kirby-image-snippet
Usage
Snippet
<?php snippet('image', ['image' => $page->images()->first()]); ?>
Field methods
<div data-cover='<?= $page->images()->first()->toImageInterface()->toJson(); ?>' data-images='<?= $page->images()->toImageInterfaces()->toJson(); ?>'></div>
Options
You can override the default options on a per image basis.
<?php snippet('image', ['image' => $page->images()->first(), 'ratio' => 1, 'dimensions' => [200]]); ?>
<div data-cover='<?= $page->images()->first()->toImageInterface(['ratio' => 1, 'dimensions' => [200]])->toJson(); ?>'></div>
Lazy Loading
You can activate lazy loading by defining lazy => true inside the options. The snippet will then add data-lazyload to the picture element and add the srcset as data-srcset to each <source>. You then have to use your own javascript implementation to lazyload the images.
Configuration
Default
You can override the default configuration in your websites site/config.php.
<?php return [ 'femundfilou.image-snippet' => [ 'placeholder' => [ 'width' => 50, 'blur' => 10, 'quality' => 50 ], 'ratio' => 0, 'quality' => 80, 'blur' => 0, 'grayscale' => false, 'lazy' => false, 'formats' => ['webp', 'jpg'], 'dimensions' => [400, 800, 1140], 'sizes' => '100vw' ] ]; ?>
统计信息
- 总下载量: 4.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-22