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 Abstract class and implementing the Modifier method.
Classes/Image/Modifier/CustomModifier.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,
];
}
}
Copied!
See the Intervention Image documentation for more information about image manipulation.
The Abstract merges the defaults from
$GLOBALS for your class into the
configuration, validates it with validate and throws an
Invalid if it is invalid.