From b713f6be61b82c2a0a580ab20c42135adc91ba8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 5 Mar 2026 16:13:18 +0100 Subject: [PATCH 1/6] Added doc for ConfigureImageOptimizersEvent --- .../src/Event/RemovePngquantOptimizer.php | 22 +++++++++++++++++++ composer.json | 3 ++- docs/api/event_reference/other_events.md | 10 +++++++++ docs/content_management/images/images.md | 11 ++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 code_samples/back_office/images/src/Event/RemovePngquantOptimizer.php diff --git a/code_samples/back_office/images/src/Event/RemovePngquantOptimizer.php b/code_samples/back_office/images/src/Event/RemovePngquantOptimizer.php new file mode 100644 index 00000000000..91d30ab9a7a --- /dev/null +++ b/code_samples/back_office/images/src/Event/RemovePngquantOptimizer.php @@ -0,0 +1,22 @@ + 'onConfigureOptimizers', + ]; + } + + public function onConfigureOptimizers(ConfigureImageOptimizersEvent $event): void + { + $event->removeOptimizer(Pngquant::class); + } +} diff --git a/composer.json b/composer.json index 690d297d966..2467d6a85f2 100644 --- a/composer.json +++ b/composer.json @@ -76,7 +76,8 @@ "ibexa/collaboration": "~4.6.x-dev", "ibexa/share": "~4.6.x-dev", "ibexa/phpstan": "~4.6.-dev", - "ibexa/cdp": "~4.6.x-dev" + "ibexa/cdp": "~4.6.x-dev", + "ibexa/image-editor": "~4.6.x-dev" }, "scripts": { "fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots", diff --git a/docs/api/event_reference/other_events.md b/docs/api/event_reference/other_events.md index 569e71a117e..413d06a95c5 100644 --- a/docs/api/event_reference/other_events.md +++ b/docs/api/event_reference/other_events.md @@ -60,6 +60,16 @@ The following events are dispatched when changing the user settings available in |---|---|---| |`PublishVersionEvent`|`PublishAssetEventDispatcher::emitPublishAssetEvent`|`Content $content`
`Connector\Dam\AssetIdentifier $assetIdentifier`
`Connector\Dam\AssetSource $assetSource`| +## Image Editor + +The following event is dispatched when the Image Editor optimizes an image. +You can subscribe to it to customize the list of active image optimizers at runtime. +For more information, see [Customizing image optimizers with an event](images.md#customizing-image-optimizers-with-an-event). + +| Event | Dispatched by | Properties | +|---|---|---| +|`ConfigureImageOptimizersEvent`|`SpatieChainOptimizer::optimize()`|`array $optimizers`| + ## Form Builder [[% include 'snippets/experience_badge.md' %]] [[% include 'snippets/commerce_badge.md' %]] | Event | Dispatched by | Properties | diff --git a/docs/content_management/images/images.md b/docs/content_management/images/images.md index 2d4a6577bfc..75716d956a8 100644 --- a/docs/content_management/images/images.md +++ b/docs/content_management/images/images.md @@ -254,6 +254,17 @@ Install these libraries using your package manager, for example: sudo apt-get install optipng ``` +### Customizing image optimizers with an event + +When the Image Editor saves a modified image, the system dispatches the [`ConfigureImageOptimizersEvent`](other_events.md#image-editor) event before running the optimizer chain. +You can listen to this event to customize the list of image optimizers at runtime. + +The following example shows an event subscriber that removes the Pngquant optimizer to prevent grayscale conversion of low-saturation PNG images: + +``` php +[[= include_file('code_samples/back_office/images/src/Event/RemovePngquantOptimizer.php') =]] +``` + ## Embedding images in Rich Text The [RichText](richtextfield.md) field allows you to embed other content items within the field. From 17a793414ded01738cb82bff18cde359234284c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 5 Mar 2026 16:19:23 +0100 Subject: [PATCH 2/6] Wording --- docs/api/event_reference/other_events.md | 1 + docs/content_management/images/images.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/api/event_reference/other_events.md b/docs/api/event_reference/other_events.md index 413d06a95c5..b23493d897c 100644 --- a/docs/api/event_reference/other_events.md +++ b/docs/api/event_reference/other_events.md @@ -64,6 +64,7 @@ The following events are dispatched when changing the user settings available in The following event is dispatched when the Image Editor optimizes an image. You can subscribe to it to customize the list of active image optimizers at runtime. + For more information, see [Customizing image optimizers with an event](images.md#customizing-image-optimizers-with-an-event). | Event | Dispatched by | Properties | diff --git a/docs/content_management/images/images.md b/docs/content_management/images/images.md index 75716d956a8..dea435e0df1 100644 --- a/docs/content_management/images/images.md +++ b/docs/content_management/images/images.md @@ -254,12 +254,12 @@ Install these libraries using your package manager, for example: sudo apt-get install optipng ``` -### Customizing image optimizers with an event +### Customizing image optimizers When the Image Editor saves a modified image, the system dispatches the [`ConfigureImageOptimizersEvent`](other_events.md#image-editor) event before running the optimizer chain. You can listen to this event to customize the list of image optimizers at runtime. -The following example shows an event subscriber that removes the Pngquant optimizer to prevent grayscale conversion of low-saturation PNG images: +The following example shows how to remove the Pngquant optimizer to prevent grayscale conversion of low-saturation PNG images: ``` php [[= include_file('code_samples/back_office/images/src/Event/RemovePngquantOptimizer.php') =]] From f1302eaa22478739859728b763320897a14e229a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Thu, 5 Mar 2026 16:25:55 +0100 Subject: [PATCH 3/6] Fixed link --- docs/api/event_reference/other_events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/event_reference/other_events.md b/docs/api/event_reference/other_events.md index b23493d897c..98464fc5ff6 100644 --- a/docs/api/event_reference/other_events.md +++ b/docs/api/event_reference/other_events.md @@ -65,7 +65,7 @@ The following events are dispatched when changing the user settings available in The following event is dispatched when the Image Editor optimizes an image. You can subscribe to it to customize the list of active image optimizers at runtime. -For more information, see [Customizing image optimizers with an event](images.md#customizing-image-optimizers-with-an-event). +For more information, see [Customizing image optimizers with an event](images.md#customizing-image-optimizers). | Event | Dispatched by | Properties | |---|---|---| From 5a78f52b2fb06d2253e28f7b516ca48ff29a3302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Fri, 6 Mar 2026 09:09:05 +0100 Subject: [PATCH 4/6] Added PHP API link --- docs/api/event_reference/other_events.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/api/event_reference/other_events.md b/docs/api/event_reference/other_events.md index 98464fc5ff6..ae980966ca7 100644 --- a/docs/api/event_reference/other_events.md +++ b/docs/api/event_reference/other_events.md @@ -69,7 +69,8 @@ For more information, see [Customizing image optimizers with an event](images.md | Event | Dispatched by | Properties | |---|---|---| -|`ConfigureImageOptimizersEvent`|`SpatieChainOptimizer::optimize()`|`array $optimizers`| +|[`ConfigureImageOptimizersEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ImageEditor-Event-ConfigureImageOptimizersEvent.html) +|`SpatieChainOptimizer::optimize()`|`array $optimizers`| ## Form Builder [[% include 'snippets/experience_badge.md' %]] [[% include 'snippets/commerce_badge.md' %]] From cd7ca0bccd8ab2d7daf6574c42139211cd7ffb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 9 Mar 2026 09:32:59 +0100 Subject: [PATCH 5/6] Fixed table formatting --- docs/api/event_reference/other_events.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/api/event_reference/other_events.md b/docs/api/event_reference/other_events.md index ae980966ca7..74be8553cef 100644 --- a/docs/api/event_reference/other_events.md +++ b/docs/api/event_reference/other_events.md @@ -69,8 +69,7 @@ For more information, see [Customizing image optimizers with an event](images.md | Event | Dispatched by | Properties | |---|---|---| -|[`ConfigureImageOptimizersEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ImageEditor-Event-ConfigureImageOptimizersEvent.html) -|`SpatieChainOptimizer::optimize()`|`array $optimizers`| +|[`ConfigureImageOptimizersEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ImageEditor-Event-ConfigureImageOptimizersEvent.html)|`SpatieChainOptimizer::optimize()`|`array $optimizers`| ## Form Builder [[% include 'snippets/experience_badge.md' %]] [[% include 'snippets/commerce_badge.md' %]] From 3c55e1fc0ce9d606268306481e5a1e05e9c26526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Mon, 9 Mar 2026 09:42:16 +0100 Subject: [PATCH 6/6] More formatting --- docs/api/event_reference/other_events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/event_reference/other_events.md b/docs/api/event_reference/other_events.md index 74be8553cef..7216c52f7ab 100644 --- a/docs/api/event_reference/other_events.md +++ b/docs/api/event_reference/other_events.md @@ -69,7 +69,7 @@ For more information, see [Customizing image optimizers with an event](images.md | Event | Dispatched by | Properties | |---|---|---| -|[`ConfigureImageOptimizersEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ImageEditor-Event-ConfigureImageOptimizersEvent.html)|`SpatieChainOptimizer::optimize()`|`array $optimizers`| +|[`ConfigureImageOptimizersEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ImageEditor-Event-ConfigureImageOptimizersEvent.html)|`SpatieChainOptimizer::`
`optimize`|`array $optimizers`| ## Form Builder [[% include 'snippets/experience_badge.md' %]] [[% include 'snippets/commerce_badge.md' %]]