定制 justbetter/statamic-glide-directive 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

justbetter/statamic-glide-directive

Composer 安装命令:

composer require justbetter/statamic-glide-directive

包简介

Addon that adds a glide blade directive

README 文档

README

Banner

Statamic Glide Directive

  • 🚀 Automatic responsive images - Optimizes images for all devices automatically.
  • ⚡ Performance boost - Serves correctly sized images, reducing load times and bandwidth.
  • 🧩 Simple syntax - Clean @responsive directive replaces complex <picture> tags.
  • 🔄 WebP support - Automatically delivers modern image formats to compatible browsers.

Installation

composer require justbetter/statamic-glide-directive

Usage

This package adds a Blade directive. You can use an asset in the directive, and it will render the image according to the presets defined in the config. Here's an example:

@responsive($image, [
    'alt' => 'This is an alt text.', 
    'class' => 'some classes here',
    'loading' => 'lazy',
    'max_width' => 320
])

When max_width (or rendered_width) is provided, srcset candidates are capped to that rendered width at 2x DPR.

To allow images to change on resize, include this in your head:

@include('statamic-glide-directive::partials.head')

Image Generation

Images are served directly through custom routes that properly handle the content type and caching. When a preset image is requested, it's generated on demand and stored in the public directory. If an image preset hasn't been generated yet, a placeholder will be used temporarily until the optimized version is ready.

We recommend pre-generating your presets for optimal performance:

php please assets:generate-presets

Config

The package has default configurations. By default, it will use the presets defined in this addon's config. If you've defined your asset presets in the Statamic config, those will be used.

Default config:

'presets' => [
    'placeholder' => ['w' => 32, 'h' => 32, 'q' => 100, 'fit' => 'contain'],
    'xs' => ['w' => 320, 'h' => 320, 'q' => 70, 'fit' => 'contain', 'lossless' => false],
    'sm' => ['w' => 480, 'h' => 480, 'q' => 75, 'fit' => 'contain', 'lossless' => false],
    'md' => ['w' => 768, 'h' => 768, 'q' => 80, 'fit' => 'contain', 'lossless' => false],
    'lg' => ['w' => 1280, 'h' => 1280, 'q' => 82, 'fit' => 'contain', 'lossless' => false],
    'xl' => ['w' => 1440, 'h' => 1440, 'q' => 82, 'fit' => 'contain', 'lossless' => false],
    '2xl' => ['w' => 1680, 'h' => 1680, 'q' => 82, 'fit' => 'contain', 'lossless' => false],
],

Image Resize Threshold

This setting defines the threshold width for image source sets. Images wider than this threshold will be processed differently to optimize performance.

'image_resize_threshold' => 480

Placeholder

On page load, a small variant of the image will be loaded. To disable this, set the placeholder in the config file:

'placeholder' => true,

Sources

Configure which sources to use. By default, only WebP sources are used. You can also configure sources based on the image MIME type or use both.

'sources' => 'webp',

Publish Configuration

php artisan vendor:publish --provider="JustBetter\ImageOptimize\ServiceProvider"

justbetter/statamic-glide-directive 适用场景与选型建议

justbetter/statamic-glide-directive 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.72k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 justbetter/statamic-glide-directive 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 justbetter/statamic-glide-directive 我们能提供哪些服务?
定制开发 / 二次开发

基于 justbetter/statamic-glide-directive 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 24
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-05-17