Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);

namespace App\Event;

use Ibexa\Contracts\ImageEditor\Event\ConfigureImageOptimizersEvent;
use Spatie\ImageOptimizer\Optimizers\Pngquant;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class RemovePngquantOptimizer implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ConfigureImageOptimizersEvent::class => 'onConfigureOptimizers',
];
}

public function onConfigureOptimizers(ConfigureImageOptimizersEvent $event): void
{
$event->removeOptimizer(Pngquant::class);
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions docs/api/event_reference/other_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@
|---|---|---|
|`PublishVersionEvent`|`PublishAssetEventDispatcher::emitPublishAssetEvent`|`Content $content`</br>`Connector\Dam\AssetIdentifier $assetIdentifier`</br>`Connector\Dam\AssetSource $assetSource`|

## Image Editor

Check notice on line 63 in docs/api/event_reference/other_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/other_events.md#L63

[Ibexa.SentenceCapitalizationInHeadings] Use sentence-style capitalization in headings
Raw output
{"message": "[Ibexa.SentenceCapitalizationInHeadings] Use sentence-style capitalization in headings", "location": {"path": "docs/api/event_reference/other_events.md", "range": {"start": {"line": 63, "column": 4}}}, "severity": "INFO"}

The following event is dispatched when the Image Editor optimizes an image.

Check notice on line 65 in docs/api/event_reference/other_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/other_events.md#L65

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/api/event_reference/other_events.md", "range": {"start": {"line": 65, "column": 21}}}, "severity": "INFO"}
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).

| Event | Dispatched by | Properties |
|---|---|---|
|<nobr>[`ConfigureImageOptimizersEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ImageEditor-Event-ConfigureImageOptimizersEvent.html)</nobr>|`SpatieChainOptimizer::`<br>`optimize`|`array<Spatie\ImageOptimizer\Optimizer> $optimizers`|

## Form Builder [[% include 'snippets/experience_badge.md' %]] [[% include 'snippets/commerce_badge.md' %]]

| Event | Dispatched by | Properties |
Expand Down
11 changes: 11 additions & 0 deletions docs/content_management/images/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ Install these libraries using your package manager, for example:
sudo apt-get install optipng
```

### 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 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') =]]
```

## Embedding images in Rich Text

The [RichText](richtextfield.md) field allows you to embed other content items within the field.
Expand Down
Loading