mia/statamic-image-renderer
Composer 安装命令:
composer require mia/statamic-image-renderer
包简介
README 文档
README
moodley interactive - Responsive image Statamic addon
Demo: https://responsive-image-demo.moodley.dev/
Features
- Works with Glide and Imgix
- Generates
pictureelements with the correctsizesattribute, based on your pages grid system - Supports art directed images
- Supports aspect ratios
- Works with your existing assets, no custom fieldtype needed
- Displays a single color placeholder (muted dominant color) of the image
- Supports lazySizes
Motivation
The motivation was, that we needed a solution that works with Glide and Imgix in the first place. And all CPU heavy calculations, like fallback images (e.g.: dominant color placeholder), should not be done in runtime. Further we needed the sizes attribute to be calculated based on our grid system, to make this super easy, we used col_span as a parameter, just as you are used to from Tailwind.
Installation
Install via composer:
composer require mia/statamic-image-renderer
Publish the config:
php artisan vendor:publish --tag="statamic-image-renderer-config"
If you want to use the native browser-level lazy-loading, set lazy_loading to browser inside the config.
When using lazysizes add it to your site like this:
npm install lazysizes
Then add it to your js file:
import lazySizes from 'lazysizes'
Config
The published config can be found in config/statamic-image-renderer.php and you can set up the breakpoints, the image provider and the container size for your main content.
Placeholder
Placeholders are getting generated on upload. If you add the addon to an existing site, you can generate the placeholders for all assets already uploaded with a command. To to so run php please resp:generate.
Tag Usage
In all the examples the assets field is called image in the blueprint. Can be called anything, thats up to your fieldsets/blueprint.
All parameters can be mixed, however you have to make sure, that the ratio and col_span attributes have a corresponding breakpoint set up. You can't have md:ratio="4/3" and lg:col_span="4". The parameter col_span expects a ratio to be set up.
The col_span attribute is the most important one, as it tells the browser which size of the image it should load. So the {{ resp:image }} tag should never be used without it, or the loaded image size is based on the viewport width.
Basic Tag
{{ resp:image }}
Provided Ratio
Outputs a 16/9 image on mobile and a 4/3 image on breakpoint lg and up.
{{ resp:image ratio="16/9" lg:ratio="4/3" }}
Provided Col Span
Sets the correct size on mobile and desktop and takes the page grid in account. Make sure to set up the grid in your config file correctly.
12 Cols on mobile and 4 cols on desktop:
{{ resp:image col_span="12" lg:col_span="4" }}
Set container to full width
This tells the tag, that this image is not in the page grid and is rather a fullscreen image.
{{ resp:image container_full_width="true" }}
Crop to faces (only supported with imgix)
Crop to faces in the picture instead of the focalpoint or center.
{{ resp:image crop="faces" }}
mia/statamic-image-renderer 适用场景与选型建议
mia/statamic-image-renderer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.25k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2021 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「images」 「responsive」 「imgix」 「statamic」 「glide」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mia/statamic-image-renderer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mia/statamic-image-renderer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mia/statamic-image-renderer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools for cropping, uploading to S3, serving through Imgix
A Laravel Nova field for distribute your images as array of object.
Pexels API Client for www.pexels.com
Laravel bindings and facade to generate imgix URLs and support for multiple sources.
Generate Imgix URLs.
统计信息
- 总下载量: 3.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-22
