kisonay/craft-twig-imagebase64
Composer 安装命令:
composer require kisonay/craft-twig-imagebase64
包简介
Base64 encode images within twig templates.
README 文档
README
Twig Image Base64 Encoding
A simple Twig extension to create base64-encoded strings from Craft [Image] Assets in your Twig templates.
Requirements
This Twig extension requires that you pass an instance of a Craft Asset in your Twig template. The extension will die gracefully if anything other than that is passed in as the first parameter.
Usage
Base64-encode asset
As a Twig Function
With default options
{{ image64(asset) }}
With inline set to true
{{ image64(asset, true) }}
This will return the base64-encoded string in a data URI scheme. The default value is false.
As a Twig Filter
{{ asset|image64 }}
Base64-encode thumbnail
As a Twig Function
With default options
{{ thumb64(asset) }}
With inline set to true and width to 200px
{{ thumb64(asset, 200, true) }}
Second parameter is thumbnail width, default to 100px;
Setting third parameter to true will return the base64-encoded string in a data URI scheme. The default value is false.
As a Twig Filter
{{ asset|thumb64 }}
统计信息
- 总下载量: 4.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-10