---
title: "Custom modifiers"
manual: "Environment Indicator"
version: "main"
permalink: "https://docs.typo3.org/permalink/konradmichalik/typo3-environment-indicator:custom-modifiers@main"
source: "DeveloperCorner/CustomModifiers.rst"
rendered: "2026-11-27T12:31:32+00:00"
---

# Custom modifiers {#custom-modifiers}

The predefined modifiers are not enough for your use case? No problem! You can easily write your own.

Implement your own image modifier by extending the `AbstractModifier` class and implementing the `ModifierInterface` method.

**Classes/Image/Modifier/CustomModifier.php**

```php
<?php

namespace Vendor\YourExt\Image\Modifier;

use Intervention\Image\Interfaces\ImageInterface;
use KonradMichalik\Typo3EnvironmentIndicator\Image\Modifier\AbstractModifier;
use KonradMichalik\Typo3EnvironmentIndicator\Image\Modifier\ModifierInterface;

class CustomModifier extends AbstractModifier implements ModifierInterface {

    public function modify(ImageInterface &$image): void
    {
        // Modify the image using $this->configuration
    }

    public function validateConfigurationWithErrors(array $configuration): array
    {
        $errors = [];

        if (!isset($configuration['myRequiredKey'])) {
            $errors[] = 'Missing required configuration key: myRequiredKey';
        }

        return [
            'valid' => [] === $errors,
            'errors' => $errors,
        ];
    }
}
```

> [!NOTE]
> **See also**
>
> View the sources on GitHub:
>
> -   [AbstractModifier](https://github.com/konradmichalik/typo3-environment-indicator/blob/main/Classes/Image/Modifier/AbstractModifier.php)
> -   [ModifierInterface](https://github.com/konradmichalik/typo3-environment-indicator/blob/main/Classes/Image/Modifier/ModifierInterface.php)

See the [Intervention Image documentation](http://image.intervention.io/v3) for more information about image
manipulation.

The `AbstractModifier` merges the defaults from
`$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['typo3_environment_indicator']['defaults']` for your class into the
configuration, validates it with `validateConfigurationWithErrors()` and throws an
`InvalidArgumentException` if it is invalid.
