legrisch/statamic-graphql-thumbnails
Composer 安装命令:
composer require legrisch/statamic-graphql-thumbnails
包简介
A Statamic CMS GraphQL Addon that provides a convenient thumbnail field on all asset fields.
README 文档
README
This Statamic GraphQL addon provides a thumbnail field on all AssetInterface fields. Either provide the argument name to query by predefined formats or use Just-In-Time thumbnail generation and provide width, height or fit.
Features
- Predefined thumbnail Formats: Query by
name - Just-In-Time thumbnail: Query by
width,heightorfit - Control Panel UI to define formats and enable/disable JIT thumbnail generation
- Permissions for managing GraphQL thumbnail Settings
Installation
Run composer require legrisch/statamic-graphql-thumbnails
Setup
After installation, you must visit the control panel to define formats to query for or enable the JIT thumbnail generation.
Usage
Formats Usage
The thumbnail field requires an argument name which resolves to the name of one of your formats.
If formats are defined, you can also directly access a property srcset on the Asset.
asset { thumbnail(name: "small") srcset }
yields
"asset": { "thumbnail": "http://absolute.url/to/thumbnail-small.jpg", "srcset": "http://absolute.url/to/thumbnail-small.jpg 500w, http://absolute.url/to/thumbnail-medium.jpg 1000w", }
JIT Usage
The thumbnail field requires an argument width or height with an integer. Additionally you may specify the parameter fit. The possible values are: contain, max, fill, stretch, crop, crop_focal with the default being crop_focal.
asset { thumbnail(width: 100) }
yields
"asset": { "thumbnail": "http://absolute.url/to/thumbnail-with-100px-width.jpg" }
Full Examples
Query single thumbnail
query MyQuery { entries(collection: "pages") { data { ... on Entry_Pages_Pages { image { id thumbnail(width: 200) } } } } }
yields
{
"data": {
"entries": {
"data": [
{
"image": {
"id": "assets::20210409232458.jpg",
"thumbnail": "http://absolute.url/to/thumbnail.jpg"
}
}
]
}
}
}
Query multiple thumbnails
Use GraphQL aliases to query multiple thumbnails:
query MyQuery { entries(collection: "pages") { data { ... on Entry_Pages_Pages { image { id thumbnailSmall: thumbnail(width: 100) thumbnailMedium: thumbnail(width: 250) thumbnailLarge: thumbnail(width: 500) thumbnailSquare: thumbnail(width: 500, height: 200, fit: "crop") } } } } }
yields
{
"data": {
"entries": {
"data": [
{
"image": {
"id": "assets::20210409232458.jpg",
"thumbnailSmall": "http://absolute.url/to/small/thumbnail.jpg",
"thumbnailMedium": "http://absolute.url/to/medium/thumbnail.jpg",
"thumbnailLarge": "http://absolute.url/to/large/thumbnail.jpg",
"thumbnailSquare": "http://absolute.url/to/square/thumbnail.jpg"
}
}
]
}
}
}
License
This project is licensed under the MIT License.
legrisch/statamic-graphql-thumbnails 适用场景与选型建议
legrisch/statamic-graphql-thumbnails 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 222 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 legrisch/statamic-graphql-thumbnails 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 legrisch/statamic-graphql-thumbnails 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 222
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-19
