Proxy objects for ImageSources that can be edited in the inspector directly and allow editing of images and image collections together with alt and title for each item.
- Christian Pansch - [email protected]
- Martin Ficzel - [email protected]
The development and the public-releases of this package is generously sponsored by our employer http://www.sitegeist.de.
Sitegeist.Kaleidoscope.ValueObjects is available via packagist run composer require sitegeist/kaleidoscope-valueobjects
.
We use semantic versioning so every breaking change will increase the major-version number.
Single images are edited via property type Sitegeist\Kaleidoscope\ValueObjects\ImageSourceProxy
.
imageSourceProxy:
type: 'Sitegeist\Kaleidoscope\ValueObjects\ImageSourceProxy'
defaultValue: null
ui:
label: 'Image'
inspector:
group: imageWithMetadata
Lists of images are edited via property type Sitegeist\Kaleidoscope\ValueObjects\ImageSourceProxyCollection
.
imageSourceProxyCollection:
type: 'Sitegeist\Kaleidoscope\ValueObjects\ImageSourceProxyCollection'
defaultValue: []
ui:
label: 'Images'
inspector:
group: imageWithMetadata
For properties of type Sitegeist\Kaleidoscope\ValueObjects\ImageSourceProxy
and ...\ImageSourceProxyCollection
dedicated inspector editors Sitegeist.Kaleidoscope.ValueObjects/Inspector/Editors/AssetWithMetadataEditor
and .../AssetWithMetadataCollectionEditor
are provided and configured for the Proxy Objects. The Editor Configuration is derived from the options as the Neos ImageEditor
as is documented here.
maximumFileSize
(string) Set the maximum allowed file size to be uploaded. Accepts numeric or formatted string values, e.g. "204800" or "204800b" or "2kb". Defaults to the maximum allowed upload size configured in php.iniconstraints
mediaTypes
(array) If set, the media browser and file upload will be limited to assets with the specified media type. Default['image/*']
Example:['image/png', 'image/jpeg']
Note: Due to technical limitations the media browser currently ignores the media sub type, soimage/png
has the same effect asimage/*
assetSources
(array) If set, the media browser will be limited to assets of the specified asset source. Default:[]
(all asset sources) Example:['neos', 'custom_asset_source]
features
crop
(boolean) Iftrue
, enable image cropping. Defaulttrue
.upload
(boolean) Iftrue
, enable Upload button, allowing new files to be uploaded directly in the editor. Defaulttrue
.mediaBrowser
(boolean) Iftrue
, enable Media Browser button. Defaulttrue
.
resize
(boolean) Iftrue
, enable image resizing. DefaultFALSE
.crop
crop-related options. Only relevant iffeatures.crop
is enabled.aspectRatio
forceCrop
(boolean) Show the crop dialog on image uploadlocked
Locks the aspect ratio to a specific width/height ratiowidth
(integer) width of the aspect ratio which shall be enforcedheight
(integer) height of the aspect ratio which shall be enforced
options
aspect-ratio presets. Only effective iflocked
is not set.[presetIdentifier]
width
(required integer) the width of the aspect ratio presetheight
(required integer) the height of the aspect ratio presetlabel
(string) human-readable name of the aspect ratio preset
enableOriginal
(boolean) Iftrue
, the image ratio of the original image can be chosen in the selector. Only effective iflocked
is not set. Defaulttrue
.allowCustom
(boolean) Iftrue
, a completely custom image ratio can be chosen. Only effective iflocked
is not set. Defaulttrue
.defaultOption
(string) default aspect ratio option to be chosen if no cropping has been applied already.
disabled
(boolean) Iftrue
, disables the ImageEditor.
When one of the proxy objects is passed to a Sitegeist.Kaleidoscope.Image|Picture|Source
prototype as imageSource
the value is automatically converted into an ImageSourceInterface
.
example = Sitegeist.Kaleidoscope:Image {
imageSource = ${q(node).property('imageSourceProxy')}
}
If you need more control over the conversion from proxies to image sources you can use you can use the Kaleidoscope.ValueObjects
helper.
Be careful as those methods only allow the ImageSourceProxy
, ImageSourceProxyCollection
and null
as parameter.
imageSource = ${Sitegeist.Kaleidoscope.ValueObjects.unwrapProxy(q(node).property('imageSourceProxy'))}
imageSources = ${Sitegeist.Kaleidoscope.ValueObjects.unwrapProxyCollection(q(node).property('imageSourceProxyCollection'))}
There are also fusion prototypes that will check the type of the given value convert ImageSourceProxy
,
ImageSourceProxyCollection
but leave all other values untouched.
# read imageSourceProxy and convert to imageSource
imageSource = ${q(node).property('imageSourceProxy')}
[email protected] = Sitegeist.Kaleidoscope.ValueObjects:ImageSourceProxyUnwrapper
imageSources = ${q(node).property('imageSourceProxyCollection')}
[email protected] = Sitegeist.Kaleidoscope.ValueObjects:ImageSourceProxyCollectionUnwrapper
To build the javascript for the inspector-editors the following docker commands can be used.
# run development build
docker run -it -v $(pwd):/app -w /app node:23 sh -c "yarn && yarn build:dev"
# run production build
docker run -it -v $(pwd):/app -w /app node:23 sh -c "yarn && yarn build"
We will gladly accept contributions. Please send us pull requests.