dev-master
9999999-devNeos CMS SQIP image renderer
MIT
The Requires
Neos CMS SQIP image renderer
This package provides a fusion object for Neos CMS to render svg image placeholders based on the SQIP technique. They can be used to show a blurry or abstract version of an image while the real image is still lazy loading., (*2)
You can see it in action here., (*3)
Learn more about SQIP is a method to generate SVG based placeholders for images here: * Original node.js version sqip used by this package. * The go variant which is also supported via configuration., (*4)
Attention: the node.js based sqip
is not released in version 1 yet.
Therefore breaking changes might happen when you use the global binary and you might need to adjust
the arguments in the settings or wait for an update of this package., (*5)
Requires npm (node.js) to work out of the box, although binaries can also be installed manually without it., (*6)
composer require shel/neos-sqip
Ensure the image manipulation library sqip
is installed globally., (*7)
Alternatively install them using npm
:, (*8)
npm install -g sqip
npm install --prefix Packages/Plugins/Shel.Neos.Sqip/Resources/Private/Library
Use the provided fusion object Shel.Neos.Sqip:ImageTag
to render an image with placeholder and use
the lazy image loader layzr to lazy load the actual images.
This object already provides the necessary attributes to make layzr
work out of the box., (*9)
You can also use the provided Shel.Neos.Sqip:SqipImage
fusion object to just render the SVG data which you can
put into the src
attribute of an img
tag or in a inline style as background image., (*10)
The fusion object Shel.Neos.Sqip:SqipCaseRenderer
provides a renderer for your src
attribute which checks
if the user is in the backend and then decides to render the original image uri instead of the SQIP image., (*11)
You can use this for example to modify the Carbon.Image:Tag object like this:, (*12)
prototype(Carbon.Image:Tag) { attributes { src > src = Shel.Neos.Sqip:SqipCaseRenderer { asset = ${asset} } srcset > data-normal = Carbon.Image:ImageUri data-srcset = Carbon.Image:Srcset } }
This package was tested with pngs, jpegs and svgs. Possibly other formats work well too., (*13)
Processing the SQIP placeholders is quite slow and takes several seconds per image., (*14)
To speed this up a thumbnail will be generated first (which can also be prerendered with CLI commands) to reduce the image dimensions. By default the preset from the Media Browser will be used which has dimensions of 250x250. So this is also a bit faster as the media module reuses the same thumbnails., (*15)
You can change the preset via configuration., (*16)
Shel: Neos: Sqip: useGlobalBinary: false # use globally installed binaries globalBinaryPath: '' library: 'sqip' binaryPath: '.bin/sqip' arguments: "${'node ' + binaryPath + ' -n ' + numberOfPrimitives + ' -m ' + mode + ' -b ' + blur + ' ' + file}" parameters: # Customize the number of primitive SVG shapes (default=8) to influence bytesize or level of detail numberOfPrimitives: 8 # Specify the type of primitive shapes that will be used to generate the image # 0=combo, 1=triangle, 2=rect, 3=ellipse, 4=circle, 5=rotatedrect, 6=beziers, 7=rotatedellipse, 8=polygon mode: 0 # Set the gaussian blur blur: 12 thumbnailPreset: 'Neos.Media.Browser:Thumbnail'
The go version is faster than the node.js version and has less dependencies but currently doesn't provide the blur parameter. Both binaries have the same cli output and therefore work fine., (*17)
sqip
binary like described in their instructions.Override the package settings in your own package like this:, (*18)
Shel: Neos: Sqip: useGlobalBinary: true globalBinaryPath: '/path/to/your/go/bin/' # Adapt this to your system arguments: "${binaryPath + ' -n ' + numberOfPrimitives + ' -mode ' + mode + ' ' + file}" parameters: # Customize the number of primitive SVG shapes (default=8) to influence bytesize or level of detail numberOfPrimitives: 8 # Specify the type of primitive shapes that will be used to generate the image # 0=combo, 1=triangle, 2=rect, 3=ellipse, 4=circle, 5=rotatedrect, 6=beziers, 7=rotatedellipse, 8=polygon mode: 0
The generated SVGs will be cached in the filesystem as strings., (*19)
To speed the Cache up you can switch to use Redis like this in your Caches.yaml
:, (*20)
ShelNeosSqip_ImageCache: backend: Neos\Cache\Backend\RedisBackend backendOptions: database: 0
You can make the cache persistent to keep cached images when temporary caches are flushed:, (*21)
ShelNeosSqip_ImageCache: persistent: true
Neos CMS SQIP image renderer
MIT