定制 sitegeist/lazybones 二次开发

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

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

sitegeist/lazybones

最新稳定版本:v3.1.2

Composer 安装命令:

composer require sitegeist/lazybones

包简介

Lazy loading for sitegeist/kaleidoscope

README 文档

README

!!! With the general availability of loading="lazy" for images in webbrowsers this package is obsolete. Please use Sitegeist.Kaleidoscope directly !!!

Responsive Images for Neos - with Atomic.Fusion & Monocle in mind

This package implements Lazy Loading for Responsive Images from the Sitegeist.Kaleidoscope package.

This is implemented by rendering the src, srcset and sizes attributes as data-src, data-srcset and data-sizes. The img- or pPicture-tag is then marked with the class lazyload to be replaced via js once the image comes into view. If you like you can render a very lowres src-attribute or leave the src attribute empty (default).

Authors & Sponsors

The development and the public-releases of this package is generously sponsored by our employer http://www.sitegeist.de.

Installation

Sitegeist.Lazybones is available via packagist run composer require sitegeist/lazybones. We use semantic-versioning so every breaking change will increase the major-version number.

Settings

The default-lazyness is controlled by the setting 'Sitegeist.Lazybones.default.lazyEnabled' and is active by default except in FLOW_CONTEXT=Development/VisualRegressionTesting.

Sitegeist: Lazybones: default: lazyEnabled: true 

Usage

LazyloadJS

To enable lazy loading you have to integrate a script that will detect the lazyload class and convert data-src, data-srcset and data-sizes to the correct attributes once they come into view.

This package includes the lazysizes library from https://github.com/aFarkas/lazysizes but it is probably better to include the js into your own fe-build.

To include the bundled js you can use the following snippet:

lazyloadJS = Neos.Fusion:Tag { tagName = 'script' attributes.async = true attributes.src = Neos.Fusion:ResourceUri { path = 'resource://Sitegeist.Lazybones/Public/JavaScript/lazysizes.min.js' } } 

Sitegeist.Lazybones:Image

Render an img-tag with optional srcset based on sizes or resolutions.

This prototype is a drop in replacement for Sitegeist.Kaleidoscope:Image with optional props to control the lazy loading.

See: https://github.com/sitegeist/Sitegeist.Kaleidoscope#sitegeistkaleidoscopeimage

Props:

  • lazy: Enable lazy loading (boolean, defaults to Sitegeist.Lazybones:Lazy.Enabled)
  • lazyClass: The class to attach to the img-tags (string, defaults to Sitegeist.Lazybones:Lazy.ClassName)
  • lazyWidth: The width of the thumbnail-src that is loaded first (string, defaults to Sitegeist.Lazybones:Lazy.Width)

Props from Sitegeist.Kaleidoscope:Image:

  • imageSource: the imageSource to render
  • srcset: media descriptors like '1.5x' or '600w' of the default image (string or array)
  • sizes: sizes attribute of the default image (string or array)
  • format: (optional) the image-format like webp or png, will be applied to the imageSource
  • width: (optional) the base width, will be applied to the imageSource
  • height: (optional) the base height, will be applied to the imageSource
  • alt: alt-attribute for the img tag
  • title: title attribute for the img tag
  • class: class attribute for the img tag
  • renderDimensionAttributes: render width/height attributes if data is available from the imageSource (boolean)

Sitegeist.Lazybones:Picture

Render a picture-tag with various sources.

This prototype is a drop in replacement for Sitegeist.Kaleidoscope:Picture with optional props to control the lazy loading.

See: https://github.com/sitegeist/Sitegeist.Kaleidoscope#sitegeistkaleidoscopepicture

Props:

  • lazy: Enable lazy loading (boolean, defaults to Sitegeist.Lazybones:Lazy.Enabled)
  • lazyClass: The class to attach to the img-tags (string, defaults to Sitegeist.Lazybones:Lazy.ClassName)
  • lazyWidth: The width of the thumbnail-src that is loaded first (string, defaults to Sitegeist.Lazybones:Lazy.Width)

Props from Sitegeist.Kaleidoscope:Picture:

  • imageSource: the imageSource to render
  • sources: an array of source definitions that supports the following keys
    • media: the media query of this source
    • type: the type of this source
    • imageSource: alternate image-source for art direction purpose
    • srcset: media descriptors like '1.5x' or '600w' (string or array)
    • sizes: sizes attribute (string or array)
    • width: (optional) the base width, will be applied to the imageSource
    • height: (optional) the base height, will be applied to the imageSource
    • format: (optional) the image-format for the source like webp or png, is applied to imageSource and type
  • srcset: media descriptors like '1.5x' or '600w' of the default image (string or array)
  • sizes: sizes attribute of the default image (string or array)
  • formats: (optional) image formats that will be rendered as sources of separate type (string or array)
  • width: (optional) the base width, will be applied to the imageSource
  • height: (optional) the base height, will be applied to the imageSource
  • alt: alt-attribute for the picture tag
  • title: title attribute for the picture tag
  • class: class attribute for the picture tag
  • renderDimensionAttributes: render dimension attributes (width/height) for the img-tag when the data is available from the imageSource

Sitegeist.Lazybones:Source

Render a source-tag with optional srcset based on sizes or resolutions.

This prototype is a drop in replacement for Sitegeist.Kaleidoscope:Source with optional props to control the lazy loading.

Props:

  • lazy: Enable lazy loading (boolean, defaults to Sitegeist.Lazybones:Lazy.Enabled)

Props from Sitegeist.Kaleidoscope:Source:

  • imageSource: the imageSource to render
  • srcset: media descriptors like '1.5x' or '600w' of the default image (string or array)
  • sizes: sizes attribute of the default image (string or array)
  • media: the media query of this source
  • type: the type of this source
  • width: (optional) the base width, will be applied to the imageSource
  • height: (optional) the base height, will be applied to the imageSource
  • format: the image-format for the source like webp or png, is applied to imageSource and type

Sitegeist.Lazybones:Lazy.Enabled

Boolean value prototype with default value true that defines whether lazyness is enabled or not. Override the value of this prototype globally or for specific parts of your fusion.

NOTE: The default value comes from the configuration 'Sitegeist.Lazybones.default.lazyEnabled' and is active by default except in FLOW_CONTEXT=Development/VisualRegressionTesting.

Sitegeist.Lazybones:Lazy.ClassName

String value prototype with default value lazyload to define the class that marks lazyloaded images. Override the value of this prototype globally or for specific parts of your fusion.

Sitegeist.Lazybones:Lazy.Width

Integer value prototype with default value null to define the size of lowres images that are loaded as placeholders. Override zhe value of this prototype globally or for specific parts of your fusion.

Dynamically enable/disable the lazy rendering

To optimize the intial load time lazy loading should be disabled for the first contents but be enabled for others. This can be implemented by enabeling the lazy in the ContentCase prototype depending on wether or not the curent node is the first content in the main collection.

content = Neos.Neos:ContentCollection { nodePath = 'main' content.iterationName = 'mainContentIterator' // enable lazynes for all but first content prototype(Sitegeist.Lazybones:Lazy.Enabled) { value = ${!mainContentIterator.isFirst} } } 

Contribution

We will gladly accept contributions. Please send us pull requests.

sitegeist/lazybones 适用场景与选型建议

sitegeist/lazybones 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 119.15k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 119.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 21
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2026-01-04