artemdanilov/flexipic 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

artemdanilov/flexipic

Composer 安装命令:

composer require artemdanilov/flexipic

包简介

Statamic addon for generating responsive images

README 文档

README

Overview

Flexipic is a Statamic addon designed to effortlessly generate responsive images on-the-fly using Glide and integrate them seamlessly into your Statamic projects using the picture tag.

Installation

Require it using Composer.

composer require artemdanilov/flexipic

After installation, Flexipic will create config/statamic/flexipic.php file.

Usage

To enable Flexipic and generate responsive images, simply insert the following line of code wherever you intend to display an image:

{{ flexipic :src="assets" }}

or

{{ flexipic src="url_to_image" }}

It will generate a <picture> tag with <source> and <img> tags inside.

In example above, images are generated based on parameters from the config file. These parameters are necessary for global usage. However, you are free to rewrite these parameters directly in your tag:

{{ flexipic
    :src="image"
    :width="[320, 640]"
}}

In the example above, the tag will generate two images with widths of 320px and 640px respectively. As you may notice, we do not specify a height property, as the height is calculated automatically based on meta tags. If you want to set another height for your image, feel free to do so:

{{ flexipic
    :src="image"
    :width="[320, 640]"
    height="400"
}}

The tag will set a height of 400px for the first value from the width array and calculate the height for the second value.

Of course, there are more parameters you can use inside.

! If your image URL is from an external source, you need to specify a height. !

Available parameters

Flexipic supports various parameters that you can include in your tag, each of which will be generated as HTML attributes. However, certain parameters are excluded from generating attributes, like quality, fit or placeholder.

Parameters Values description
src url or path Specifies the source URL or path of the image
width [480, 768, 1024, ...] Specifies the width(s) of the image in pixels
height number Specifies the height of the image in pixels
sizes (max-width: 320px) 480px, 768px Specifies the sizes of the image in a responsive context
quality 0-100 Specifies the image quality, which affects file size and compression level
fit contain, max, fill, fill-max, stretch, crop, crop-focal Sets how the image is fitted to its target dimensions
loading eager or lazy Specifies whether the image should be loaded immediately (eager) or lazily (lazy).
placeholder "blur", "false" or your custom value Specifies whether a placeholder should be generated for lazy loading purposes
class string of classes Specifies additional CSS classes to apply to the image element.
wrapper_class string of classes Specifies additional CSS classes to apply to the picture element.

Lazyloading

If you set loading and placeholder parameters for smooth lazyload effect, you should to pass a JS function to your resources/js/site.js file

import flexipicLazyload from '../../vendor/artemdanilov/flexipic/dist/flexipicLazyload.min';

window.addEventListener('DOMContentLoaded', () => {
    flexipicLazyload('.flexipic');
})

Support

If you encounter any issues or have questions about using Flexipic, please don't hesitate to reach out to me artemdanilow@gmail.com

License

Flexipic is licensed under the MIT License. Feel free to use, modify, and distribute it according to your needs.

artemdanilov/flexipic 适用场景与选型建议

artemdanilov/flexipic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 475 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 artemdanilov/flexipic 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-23