summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-05-18 10:19:21 (GMT)
committerAlex Pott2018-05-18 10:19:21 (GMT)
commitbf864999b4381a6a026867141ae0a8e32624f8fb (patch)
tree03ef355cd18b7f313eceb32ca56d6a16beac10d8
parenta7fdfb64693d00bd7e094ccda45c3e58581b8bbe (diff)
Issue #1252606 by rlhawk, dsnopek, attiks, alansaviolobo, MariaDenysyuk, j0rd, sushyl, Adysone, Alan Evans, mondrake, andypost, alexpott, sun, tstoeckler: Add crop anchor option to Scale and Crop image effect
-rw-r--r--core/modules/image/config/schema/image.schema.yml4
-rw-r--r--core/modules/image/image.module3
-rw-r--r--core/modules/image/image.post_update.php17
-rw-r--r--core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php25
-rw-r--r--core/modules/image/src/Tests/Update/ScaleAndCropAddAnchorUpdateTest.php59
-rw-r--r--core/modules/image/templates/image-scale-and-crop-summary.html.twig32
-rw-r--r--core/modules/image/tests/fixtures/update/image.image_style.test_scale_and_crop_add_anchor.yml28
-rw-r--r--core/modules/image/tests/fixtures/update/test_scale_and_crop_add_anchor.php19
-rw-r--r--core/modules/image/tests/src/Functional/ImageEffectsTest.php25
-rw-r--r--core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php2
-rw-r--r--core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php2
-rw-r--r--core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php18
-rw-r--r--core/profiles/demo_umami/config/install/image.style.large_21_9.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.large_21_9_2x.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.large_3_2_2x.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.large_3_2_768x512.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.medium_21_9.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.medium_3_2_2x.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.medium_3_2_600x400.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.medium_8_7.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.scale_crop_7_3_large.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.small_21_9.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.square_large.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.square_medium.yml1
-rw-r--r--core/profiles/demo_umami/config/install/image.style.square_small.yml1
-rwxr-xr-x[-rw-r--r--]core/scripts/run-tests.sh0
-rw-r--r--core/themes/stable/templates/admin/image-scale-and-crop-summary.html.twig30
27 files changed, 270 insertions, 7 deletions
diff --git a/core/modules/image/config/schema/image.schema.yml b/core/modules/image/config/schema/image.schema.yml
index 924d454..4fcb6c7 100644
--- a/core/modules/image/config/schema/image.schema.yml
+++ b/core/modules/image/config/schema/image.schema.yml
@@ -76,6 +76,10 @@ image.effect.image_desaturate:
image.effect.image_scale_and_crop:
type: image_size
label: 'Image scale and crop'
+ mapping:
+ anchor:
+ label: 'Anchor'
+ type: string
image.settings:
type: config_object
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 1c00e03..c1c216c 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -152,6 +152,9 @@ function image_theme() {
'image_crop_summary' => [
'variables' => ['data' => NULL, 'effect' => []],
],
+ 'image_scale_and_crop_summary' => [
+ 'variables' => ['data' => NULL, 'effect' => []],
+ ],
'image_rotate_summary' => [
'variables' => ['data' => NULL, 'effect' => []],
],
diff --git a/core/modules/image/image.post_update.php b/core/modules/image/image.post_update.php
index 04d8c4b..cde93fc 100644
--- a/core/modules/image/image.post_update.php
+++ b/core/modules/image/image.post_update.php
@@ -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;
+ });
+}
diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php
index 57ea0b2..5f06674 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php
@@ -13,17 +13,38 @@ use Drupal\Core\Image\ImageInterface;
* description = @Translation("Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.")
* )
*/
-class ScaleAndCropImageEffect extends ResizeImageEffect {
+class ScaleAndCropImageEffect extends CropImageEffect {
/**
* {@inheritdoc}
*/
public function applyEffect(ImageInterface $image) {
- if (!$image->scaleAndCrop($this->configuration['width'], $this->configuration['height'])) {
+ $width = $this->configuration['width'];
+ $height = $this->configuration['height'];
+ $scale = max($width / $image->getWidth(), $height / $image->getHeight());
+
+ list($x, $y) = explode('-', $this->configuration['anchor']);
+ $x = image_filter_keyword($x, $image->getWidth() * $scale, $width);
+ $y = image_filter_keyword($y, $image->getHeight() * $scale, $height);
+
+ if (!$image->apply('scale_and_crop', ['x' => $x, 'y' => $y, 'width' => $width, 'height' => $height])) {
$this->logger->error('Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]);
return FALSE;
}
return TRUE;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getSummary() {
+ $summary = [
+ '#theme' => 'image_scale_and_crop_summary',
+ '#data' => $this->configuration,
+ ];
+ $summary += parent::getSummary();
+
+ return $summary;
+ }
+
}
diff --git a/core/modules/image/src/Tests/Update/ScaleAndCropAddAnchorUpdateTest.php b/core/modules/image/src/Tests/Update/ScaleAndCropAddAnchorUpdateTest.php
new file mode 100644
index 0000000..cbef409
--- /dev/null
+++ b/core/modules/image/src/Tests/Update/ScaleAndCropAddAnchorUpdateTest.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Drupal\image\Tests\Update;
+
+use Drupal\FunctionalTests\Update\UpdatePathTestBase;
+
+/**
+ * Tests adding an 'anchor' setting to existing scale and crop image effects.
+ *
+ * @see image_post_update_scale_and_crop_effect_add_anchor()
+ *
+ * @group Update
+ */
+class ScaleAndCropAddAnchorUpdateTest extends UpdatePathTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setDatabaseDumpFiles() {
+ $this->databaseDumpFiles = [
+ __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz',
+ __DIR__ . '/../../../tests/fixtures/update/test_scale_and_crop_add_anchor.php',
+ ];
+ }
+
+ /**
+ * Tests that 'anchor' setting is properly added.
+ */
+ public function testImagePostUpdateScaleAndCropEffectAddAnchor() {
+ // Test that the first effect does not have an 'anchor' setting.
+ $effect_data = $this->config('image.style.test_scale_and_crop_add_anchor')->get('effects.8c7170c9-5bcc-40f9-8698-f88a8be6d434.data');
+ $this->assertFalse(array_key_exists('anchor', $effect_data));
+
+ // Test that the second effect has an 'anchor' setting.
+ $effect_data = $this->config('image.style.test_scale_and_crop_add_anchor')->get('effects.a8d83b12-abc6-40c8-9c2f-78a4e421cf97.data');
+ $this->assertTrue(array_key_exists('anchor', $effect_data));
+
+ // Test that the third effect does not have an 'anchor' setting.
+ $effect_data = $this->config('image.style.test_scale_and_crop_add_anchor')->get('effects.1bffd475-19d0-439a-b6a1-7e5850ce40f9.data');
+ $this->assertFalse(array_key_exists('anchor', $effect_data));
+
+ $this->runUpdates();
+
+ // Test that the first effect now has an 'anchor' setting.
+ $effect_data = $this->config('image.style.test_scale_and_crop_add_anchor')->get('effects.8c7170c9-5bcc-40f9-8698-f88a8be6d434.data');
+ $this->assertTrue(array_key_exists('anchor', $effect_data));
+ $this->assertEquals('center-center', $effect_data['anchor']);
+
+ // Test that the second effect's 'anchor' setting is unchanged.
+ $effect_data = $this->config('image.style.test_scale_and_crop_add_anchor')->get('effects.a8d83b12-abc6-40c8-9c2f-78a4e421cf97.data');
+ $this->assertTrue(array_key_exists('anchor', $effect_data));
+ $this->assertEquals('left-top', $effect_data['anchor']);
+
+ // Test that the third effect still does not have an 'anchor' setting.
+ $effect_data = $this->config('image.style.test_scale_and_crop_add_anchor')->get('effects.1bffd475-19d0-439a-b6a1-7e5850ce40f9.data');
+ $this->assertFalse(array_key_exists('anchor', $effect_data));
+ }
+
+}
diff --git a/core/modules/image/templates/image-scale-and-crop-summary.html.twig b/core/modules/image/templates/image-scale-and-crop-summary.html.twig
new file mode 100644
index 0000000..b120e3f
--- /dev/null
+++ b/core/modules/image/templates/image-scale-and-crop-summary.html.twig
@@ -0,0 +1,32 @@
+{#
+/**
+ * @file
+ * Default theme implementation for a summary of an image scale and crop effect.
+ *
+ * Available variables:
+ * - data: The current configuration for this resize effect, including:
+ * - width: The width of the resized image.
+ * - height: The height of the resized image.
+ * - anchor: The part of the image that will be retained after cropping.
+ * - anchor_label: The translated label of the crop anchor.
+ * - effect: The effect information, including:
+ * - id: The effect identifier.
+ * - label: The effect name.
+ * - description: The effect description.
+ *
+ * @ingroup themeable
+ */
+#}
+{% if data.width and data.height -%}
+ {{ data.width }}×{{ data.height }}
+{%- else -%}
+ {% if data.width %}
+ {% trans %}
+ width {{ data.width }}
+ {% endtrans %}
+ {% elseif data.height %}
+ {% trans %}
+ height {{ data.height }}
+ {% endtrans %}
+ {% endif %}
+{%- endif %}
diff --git a/core/modules/image/tests/fixtures/update/image.image_style.test_scale_and_crop_add_anchor.yml b/core/modules/image/tests/fixtures/update/image.image_style.test_scale_and_crop_add_anchor.yml
new file mode 100644
index 0000000..b8dd8db
--- /dev/null
+++ b/core/modules/image/tests/fixtures/update/image.image_style.test_scale_and_crop_add_anchor.yml
@@ -0,0 +1,28 @@
+langcode: en
+status: true
+name: test_scale_and_crop_add_anchor
+label: test_scale_and_crop_add_anchor
+effects:
+ 8c7170c9-5bcc-40f9-8698-f88a8be6d434:
+ uuid: 8c7170c9-5bcc-40f9-8698-f88a8be6d434
+ id: image_scale_and_crop
+ weight: 1
+ data:
+ width: 100
+ height: 100
+ a8d83b12-abc6-40c8-9c2f-78a4e421cf97:
+ uuid: a8d83b12-abc6-40c8-9c2f-78a4e421cf97
+ id: image_scale_and_crop
+ weight: 2
+ data:
+ width: 100
+ height: 100
+ anchor: left-top
+ 1bffd475-19d0-439a-b6a1-7e5850ce40f9:
+ uuid: 1bffd475-19d0-439a-b6a1-7e5850ce40f9
+ id: image_rotate
+ weight: 3
+ data:
+ degrees: 180
+ bgcolor: ''
+ random: false
diff --git a/core/modules/image/tests/fixtures/update/test_scale_and_crop_add_anchor.php b/core/modules/image/tests/fixtures/update/test_scale_and_crop_add_anchor.php
new file mode 100644
index 0000000..4fdc033
--- /dev/null
+++ b/core/modules/image/tests/fixtures/update/test_scale_and_crop_add_anchor.php
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * @file
+ * Test fixture.
+ */
+
+use Drupal\Core\Database\Database;
+use Drupal\Core\Serialization\Yaml;
+
+$connection = Database::getConnection();
+
+$connection->insert('config')
+ ->fields([
+ 'collection' => '',
+ 'name' => 'image.style.test_scale_and_crop_add_anchor',
+ 'data' => serialize(Yaml::decode(file_get_contents('core/modules/image/tests/fixtures/update/image.image_style.test_scale_and_crop_add_anchor.yml'))),
+ ])
+ ->execute();
diff --git a/core/modules/image/tests/src/Functional/ImageEffectsTest.php b/core/modules/image/tests/src/Functional/ImageEffectsTest.php
index 3207442..f6b4ab3 100644
--- a/core/modules/image/tests/src/Functional/ImageEffectsTest.php
+++ b/core/modules/image/tests/src/Functional/ImageEffectsTest.php
@@ -111,8 +111,29 @@ class ImageEffectsTest extends ToolkitTestBase {
// Check the parameters.
$calls = $this->imageTestGetAllCalls();
- $this->assertEqual($calls['scale_and_crop'][0][0], 5, 'Width was computed and passed correctly');
- $this->assertEqual($calls['scale_and_crop'][0][1], 10, 'Height was computed and passed correctly');
+ $this->assertEqual($calls['scale_and_crop'][0][0], 7.5, 'X was computed and passed correctly');
+ $this->assertEqual($calls['scale_and_crop'][0][1], 0, 'Y was computed and passed correctly');
+ $this->assertEqual($calls['scale_and_crop'][0][2], 5, 'Width was computed and passed correctly');
+ $this->assertEqual($calls['scale_and_crop'][0][3], 10, 'Height was computed and passed correctly');
+ }
+
+ /**
+ * Test the image_scale_and_crop_effect() function with an anchor.
+ */
+ public function testScaleAndCropEffectWithAnchor() {
+ $this->assertImageEffect('image_scale_and_crop', [
+ 'anchor' => 'top-1',
+ 'width' => 5,
+ 'height' => 10,
+ ]);
+ $this->assertToolkitOperationsCalled(['scale_and_crop']);
+
+ // Check the parameters.
+ $calls = $this->imageTestGetAllCalls();
+ $this->assertEqual($calls['scale_and_crop'][0][0], 0, 'X was computed and passed correctly');
+ $this->assertEqual($calls['scale_and_crop'][0][1], 1, 'Y was computed and passed correctly');
+ $this->assertEqual($calls['scale_and_crop'][0][2], 5, 'Width was computed and passed correctly');
+ $this->assertEqual($calls['scale_and_crop'][0][3], 10, 'Height was computed and passed correctly');
}
/**
diff --git a/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php b/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php
index 190d2b9..a2a8431 100644
--- a/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php
+++ b/core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php
@@ -55,6 +55,7 @@ abstract class ImageStyleResourceTestBase extends EntityResourceTestBase {
$effect = [
'id' => 'image_scale_and_crop',
'data' => [
+ 'anchor' => 'center-center',
'width' => 120,
'height' => 121,
],
@@ -79,6 +80,7 @@ abstract class ImageStyleResourceTestBase extends EntityResourceTestBase {
'id' => 'image_scale_and_crop',
'weight' => 0,
'data' => [
+ 'anchor' => 'center-center',
'width' => 120,
'height' => 121,
],
diff --git a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
index 534a412..a15d49e 100644
--- a/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
+++ b/core/modules/image/tests/src/Kernel/Migrate/d7/MigrateImageStylesTest.php
@@ -32,7 +32,7 @@ class MigrateImageStylesTest extends MigrateDrupal7TestBase {
* Test the image styles migration.
*/
public function testImageStylesMigration() {
- $this->assertEntity('custom_image_style_1', "Custom image style 1", ['image_scale_and_crop', 'image_desaturate'], [['width' => 55, 'height' => 55], []]);
+ $this->assertEntity('custom_image_style_1', "Custom image style 1", ['image_scale_and_crop', 'image_desaturate'], [['width' => 55, 'height' => 55, 'anchor' => 'center-center'], []]);
$this->assertEntity('custom_image_style_2', "Custom image style 2", ['image_resize', 'image_rotate'], [['width' => 55, 'height' => 100], ['degrees' => 45, 'bgcolor' => '#FFFFFF', 'random' => FALSE]]);
$this->assertEntity('custom_image_style_3', "Custom image style 3", ['image_scale', 'image_crop'], [['width' => 150, 'height' => NULL, 'upscale' => FALSE], ['width' => 50, 'height' => 50, 'anchor' => 'left-top']]);
}
diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
index 510020f..ad53ec3 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php
@@ -20,6 +20,16 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
*/
protected function arguments() {
return [
+ 'x' => [
+ 'description' => 'The horizontal offset for the start of the crop, in pixels',
+ 'required' => FALSE,
+ 'default' => NULL,
+ ],
+ 'y' => [
+ 'description' => 'The vertical offset for the start the crop, in pixels',
+ 'required' => FALSE,
+ 'default' => NULL,
+ ],
'width' => [
'description' => 'The target width, in pixels',
],
@@ -38,8 +48,12 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
$scaleFactor = max($arguments['width'] / $actualWidth, $arguments['height'] / $actualHeight);
- $arguments['x'] = (int) round(($actualWidth * $scaleFactor - $arguments['width']) / 2);
- $arguments['y'] = (int) round(($actualHeight * $scaleFactor - $arguments['height']) / 2);
+ $arguments['x'] = isset($arguments['x']) ?
+ (int) round($arguments['x']) :
+ (int) round(($actualWidth * $scaleFactor - $arguments['width']) / 2);
+ $arguments['y'] = isset($arguments['y']) ?
+ (int) round($arguments['y']) :
+ (int) round(($actualHeight * $scaleFactor - $arguments['height']) / 2);
$arguments['resize'] = [
'width' => (int) round($actualWidth * $scaleFactor),
'height' => (int) round($actualHeight * $scaleFactor),
diff --git a/core/profiles/demo_umami/config/install/image.style.large_21_9.yml b/core/profiles/demo_umami/config/install/image.style.large_21_9.yml
index 7e1c7c2..f2be28f 100644
--- a/core/profiles/demo_umami/config/install/image.style.large_21_9.yml
+++ b/core/profiles/demo_umami/config/install/image.style.large_21_9.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 1440
height: 620
diff --git a/core/profiles/demo_umami/config/install/image.style.large_21_9_2x.yml b/core/profiles/demo_umami/config/install/image.style.large_21_9_2x.yml
index 13d8416..d65f5f5 100644
--- a/core/profiles/demo_umami/config/install/image.style.large_21_9_2x.yml
+++ b/core/profiles/demo_umami/config/install/image.style.large_21_9_2x.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 2880
height: 1240
diff --git a/core/profiles/demo_umami/config/install/image.style.large_3_2_2x.yml b/core/profiles/demo_umami/config/install/image.style.large_3_2_2x.yml
index e469fb6..709d3c3 100644
--- a/core/profiles/demo_umami/config/install/image.style.large_3_2_2x.yml
+++ b/core/profiles/demo_umami/config/install/image.style.large_3_2_2x.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 1536
height: 1024
diff --git a/core/profiles/demo_umami/config/install/image.style.large_3_2_768x512.yml b/core/profiles/demo_umami/config/install/image.style.large_3_2_768x512.yml
index ad8e523..59fbbb5 100644
--- a/core/profiles/demo_umami/config/install/image.style.large_3_2_768x512.yml
+++ b/core/profiles/demo_umami/config/install/image.style.large_3_2_768x512.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 768
height: 512
diff --git a/core/profiles/demo_umami/config/install/image.style.medium_21_9.yml b/core/profiles/demo_umami/config/install/image.style.medium_21_9.yml
index 43ce95a..d6b0d6a 100644
--- a/core/profiles/demo_umami/config/install/image.style.medium_21_9.yml
+++ b/core/profiles/demo_umami/config/install/image.style.medium_21_9.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 1024
height: 440
diff --git a/core/profiles/demo_umami/config/install/image.style.medium_3_2_2x.yml b/core/profiles/demo_umami/config/install/image.style.medium_3_2_2x.yml
index 3a1774f..e617feb 100644
--- a/core/profiles/demo_umami/config/install/image.style.medium_3_2_2x.yml
+++ b/core/profiles/demo_umami/config/install/image.style.medium_3_2_2x.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 1200
height: 800
diff --git a/core/profiles/demo_umami/config/install/image.style.medium_3_2_600x400.yml b/core/profiles/demo_umami/config/install/image.style.medium_3_2_600x400.yml
index f72a09d..8ae09da 100644
--- a/core/profiles/demo_umami/config/install/image.style.medium_3_2_600x400.yml
+++ b/core/profiles/demo_umami/config/install/image.style.medium_3_2_600x400.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 600
height: 400
diff --git a/core/profiles/demo_umami/config/install/image.style.medium_8_7.yml b/core/profiles/demo_umami/config/install/image.style.medium_8_7.yml
index c8af145..0283770 100644
--- a/core/profiles/demo_umami/config/install/image.style.medium_8_7.yml
+++ b/core/profiles/demo_umami/config/install/image.style.medium_8_7.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 266
height: 236
diff --git a/core/profiles/demo_umami/config/install/image.style.scale_crop_7_3_large.yml b/core/profiles/demo_umami/config/install/image.style.scale_crop_7_3_large.yml
index 5f579be..1488edd 100644
--- a/core/profiles/demo_umami/config/install/image.style.scale_crop_7_3_large.yml
+++ b/core/profiles/demo_umami/config/install/image.style.scale_crop_7_3_large.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 1440
height: 617
diff --git a/core/profiles/demo_umami/config/install/image.style.small_21_9.yml b/core/profiles/demo_umami/config/install/image.style.small_21_9.yml
index 905f23f..54cddab 100644
--- a/core/profiles/demo_umami/config/install/image.style.small_21_9.yml
+++ b/core/profiles/demo_umami/config/install/image.style.small_21_9.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 768
height: 330
diff --git a/core/profiles/demo_umami/config/install/image.style.square_large.yml b/core/profiles/demo_umami/config/install/image.style.square_large.yml
index 1bea9a5..55081c3 100644
--- a/core/profiles/demo_umami/config/install/image.style.square_large.yml
+++ b/core/profiles/demo_umami/config/install/image.style.square_large.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 900
height: 900
diff --git a/core/profiles/demo_umami/config/install/image.style.square_medium.yml b/core/profiles/demo_umami/config/install/image.style.square_medium.yml
index 5e924c7..e920ef9 100644
--- a/core/profiles/demo_umami/config/install/image.style.square_medium.yml
+++ b/core/profiles/demo_umami/config/install/image.style.square_medium.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 600
height: 600
diff --git a/core/profiles/demo_umami/config/install/image.style.square_small.yml b/core/profiles/demo_umami/config/install/image.style.square_small.yml
index 03b4b11..97b37fa 100644
--- a/core/profiles/demo_umami/config/install/image.style.square_small.yml
+++ b/core/profiles/demo_umami/config/install/image.style.square_small.yml
@@ -9,5 +9,6 @@ effects:
id: image_scale_and_crop
weight: 1
data:
+ anchor: center-center
width: 300
height: 300
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 5dc391e..5dc391e 100644..100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
diff --git a/core/themes/stable/templates/admin/image-scale-and-crop-summary.html.twig b/core/themes/stable/templates/admin/image-scale-and-crop-summary.html.twig
new file mode 100644
index 0000000..f5d5654
--- /dev/null
+++ b/core/themes/stable/templates/admin/image-scale-and-crop-summary.html.twig
@@ -0,0 +1,30 @@
+{#
+/**
+ * @file
+ * Theme override for a summary of an image scale and crop effect.
+ *
+ * Available variables:
+ * - data: The current configuration for this resize effect, including:
+ * - width: The width of the resized image.
+ * - height: The height of the resized image.
+ * - anchor: The part of the image that will be retained after cropping.
+ * - anchor_label: The translated label of the crop anchor.
+ * - effect: The effect information, including:
+ * - id: The effect identifier.
+ * - label: The effect name.
+ * - description: The effect description.
+ */
+#}
+{% if data.width and data.height -%}
+ {{ data.width }}×{{ data.height }}
+{%- else -%}
+ {% if data.width %}
+ {% trans %}
+ width {{ data.width }}
+ {% endtrans %}
+ {% elseif data.height %}
+ {% trans %}
+ height {{ data.height }}
+ {% endtrans %}
+ {% endif %}
+{%- endif %}