View source
<?php
use Drupal\image\Entity\ImageStyle;
use Drupal\image\ImageEffectInterface;
use Drupal\imagick\Plugin\ImageEffect\ConvertImageEffect;
function imagick_requirements($phase) {
$requirements = [];
if (!extension_loaded('imagick')) {
$requirements['not_installed'] = [
'title' => 'ImageMagick PHP extension',
'value' => t('Not installed'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The Imagick image toolkit requires that the Imagick extension for PHP is installed and configured properly. For more information see <a href=":url">PHP\'s ImageMagick documentation</a>.', [
':url' => 'http://php.net/manual/book.imagick.php',
]),
];
}
return $requirements;
}
function imagick_update_8001() {
$styles = ImageStyle::loadMultiple();
foreach ($styles as $style) {
foreach ($style
->getEffects() as $effect) {
if ($effect instanceof ConvertImageEffect) {
$config = $effect
->getConfiguration();
$config['data']['format'] = strtolower($config['data']['format']);
$effect
->setConfiguration($config);
$style
->save();
}
}
}
}