Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / image / image.post_update.php
index 04d8c4b7b9e31fec1df3ea889fad363508fc4155..cde93fc2e9359fbbcdca479bd99933519c007df8 100644 (file)
@@ -5,6 +5,7 @@
  * Post-update functions for Image.
  */
 
+use Drupal\Core\Config\Entity\ConfigEntityUpdater;
 use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\Core\Entity\Entity\EntityFormDisplay;
 
@@ -20,3 +21,19 @@ function image_post_update_image_style_dependencies() {
     $display->save();
   }
 }
+
+/**
+ * Add 'anchor' setting to 'Scale and crop' effects.
+ */
+function image_post_update_scale_and_crop_effect_add_anchor(&$sandbox = NULL) {
+  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'image_style', function ($image_style) {
+    /** @var \Drupal\image\ImageStyleInterface $image_style */
+    $effects = $image_style->getEffects();
+    foreach ($effects as $effect) {
+      if ($effect->getPluginId() === 'image_scale_and_crop') {
+        return TRUE;
+      }
+    }
+    return FALSE;
+  });
+}