diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php index b111486..585a1e6 100644 --- a/core/lib/Drupal/Core/Image/Image.php +++ b/core/lib/Drupal/Core/Image/Image.php @@ -189,7 +189,7 @@ public function rotate($degrees, $background = NULL) { * {@inheritdoc} */ public function scaleAndCrop($width, $height, $upscale = FALSE) { - return $this->apply('scale_and_crop', array('width' => $width, 'height' => $height, 'upscale' => $upscale)); + return $this->apply('scale_and_crop', ['width' => $width, 'height' => $height, 'upscale' => $upscale]); } /** diff --git a/core/modules/image/image.install b/core/modules/image/image.install index fd14d03..11573b9 100644 --- a/core/modules/image/image.install +++ b/core/modules/image/image.install @@ -5,6 +5,8 @@ * Install, update and uninstall functions for the image module. */ +use Drupal\image\Entity\ImageStyle; + /** * Implements hook_install(). */ @@ -61,3 +63,32 @@ function image_requirements($phase) { return $requirements; } + +/** + * @addtogroup updates-8.3.0 + * @{ + */ + +/** + * Add 'upscale' parameters to 'Scale and crop' effects. + */ +function image_update_8301() { + foreach (ImageStyle::loadMultiple() as $image_style) { + $edited = FALSE; + foreach ($image_style->getEffects() as $effect) { + if ($effect->getPluginId() === 'image_scale_and_crop') { + $configuration = $effect->getConfiguration(); + $configuration['data']['upscale'] = FALSE; + $effect->setConfiguration($configuration); + $edited = TRUE; + } + } + if ($edited) { + $image_style->save(); + } + } +} + +/** + * @} End of "addtogroup updates-8.3.0". + */ diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php index fe89b3f..56dcf70 100644 --- a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php @@ -53,10 +53,9 @@ public function transformDimensions(array &$dimensions, $uri) { * {@inheritdoc} */ public function getSummary() { - $summary = parent::getSummary(); - $summary['#theme'] = 'image_scale_and_crop_summary'; - $summary['#data'] = $this->configuration; - return $summary; + return [ + '#theme' => 'image_scale_and_crop_summary', + ] + parent::getSummary(); } /**